Mercurial > hg > octave-nkf
annotate libinterp/corefcn/graphics.cc @ 19154:d4b69559a0f7
graphics.cc (axes::properties::set_rotate3d): Fix check for 2D axes
* graphics.cc (axes::properties::set_rotate3d): Remove incorrect check
for parent figures' ndim with calc_dimensions and replace with get_is2D.
This fixes the problem in mixed 2D, 3D subplots where it was possible
to enable rotate3d for 2D plots.
author | Andreas Weber <andy.weber.aw@gmail.com> |
---|---|
date | Mon, 28 Jul 2014 09:28:57 +0200 |
parents | 52e01aa1fe8b |
children | a30e1d20fd3c |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17652
diff
changeset
|
3 Copyright (C) 2007-2013 John W. Eaton |
6406 | 4 |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
6406 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
6406 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cctype> | |
7222 | 28 #include <cfloat> |
7286 | 29 #include <cstdlib> |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
30 #include <ctime> |
6406 | 31 |
32 #include <algorithm> | |
33 #include <list> | |
34 #include <map> | |
35 #include <set> | |
36 #include <string> | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
37 #include <sstream> |
6406 | 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 | 40 #include "file-ops.h" |
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 | 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 | 49 #include "error.h" |
6595 | 50 #include "graphics.h" |
7409 | 51 #include "input.h" |
6705 | 52 #include "ov.h" |
53 #include "oct-obj.h" | |
54 #include "oct-map.h" | |
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 | 57 #include "parse.h" |
7409 | 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 | 60 #include "unwind-prot.h" |
18801
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
61 #include "octave-default-image.h" |
6595 | 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 | 66 static void |
67 gripe_set_invalid (const std::string& pname) | |
68 { | |
69 error ("set: invalid value for %s property", pname.c_str ()); | |
70 } | |
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 | 136 static Matrix |
137 jet_colormap (void) | |
138 { | |
139 Matrix cmap (64, 3, 0.0); | |
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 | 145 for (octave_idx_type i = 0; i < 64; i++) |
146 { | |
147 // This is the jet colormap. It would be nice to be able | |
148 // to feval the jet function but since there is a static | |
149 // property object that includes a colormap_property | |
150 // object, we need to initialize this before main is even | |
151 // called, so calling an interpreted function is not | |
152 // possible. | |
153 | |
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
|
154 double x = i*delta; |
7363 | 155 |
156 if (x >= 3.0/8.0 && x < 5.0/8.0) | |
157 cmap(i,0) = 4.0 * x - 3.0/2.0; | |
158 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
159 cmap(i,0) = 1.0; | |
160 else if (x >= 7.0/8.0) | |
161 cmap(i,0) = -4.0 * x + 9.0/2.0; | |
162 | |
163 if (x >= 1.0/8.0 && x < 3.0/8.0) | |
164 cmap(i,1) = 4.0 * x - 1.0/2.0; | |
165 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
166 cmap(i,1) = 1.0; | |
167 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
168 cmap(i,1) = -4.0 * x + 7.0/2.0; | |
169 | |
170 if (x < 1.0/8.0) | |
171 cmap(i,2) = 4.0 * x + 1.0/2.0; | |
172 else if (x >= 1.0/8.0 && x < 3.0/8.0) | |
173 cmap(i,2) = 1.0; | |
174 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
175 cmap(i,2) = -4.0 * x + 5.0/2.0; | |
176 } | |
177 | |
178 return cmap; | |
179 } | |
180 | |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
181 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
182 default_screendepth (void) |
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 return display_info::depth (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
185 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
186 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
187 static Matrix |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
188 default_screensize (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
189 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
190 Matrix retval (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
191 |
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 | 204 static Matrix |
205 default_colororder (void) | |
206 { | |
207 Matrix retval (7, 3, 0.0); | |
208 | |
209 retval(0,2) = 1.0; | |
210 | |
211 retval(1,1) = 0.5; | |
212 | |
213 retval(2,0) = 1.0; | |
214 | |
215 retval(3,1) = 0.75; | |
216 retval(3,2) = 0.75; | |
217 | |
218 retval(4,0) = 0.75; | |
219 retval(4,2) = 0.75; | |
220 | |
221 retval(5,0) = 0.75; | |
222 retval(5,1) = 0.75; | |
223 | |
224 retval(6,0) = 0.25; | |
225 retval(6,1) = 0.25; | |
226 retval(6,2) = 0.25; | |
227 | |
228 return retval; | |
229 } | |
230 | |
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 | 233 { |
234 Matrix m (1, 2, 0); | |
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 |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
242 m(1) = 1; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
243 |
7363 | 244 return m; |
245 } | |
246 | |
247 static Matrix | |
248 default_data (void) | |
249 { | |
250 Matrix retval (1, 2); | |
251 | |
252 retval(0) = 0; | |
253 retval(1) = 1; | |
254 | |
255 return retval; | |
256 } | |
257 | |
7427 | 258 static Matrix |
18801
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
259 default_image_cdata (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
260 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
261 Matrix m (64, 64, 0.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
262 int i = 0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
263 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:
18711
diff
changeset
|
264 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:
18711
diff
changeset
|
265 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
266 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:
18711
diff
changeset
|
267 i++; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
268 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
269 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
270 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
271 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
272 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
273 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
274 default_surface_xdata (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
275 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
276 Matrix m (3, 3, 0.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
277 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:
18711
diff
changeset
|
278 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:
18711
diff
changeset
|
279 m(row,col) = col+1; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
280 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
281 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
282 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
283 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
284 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
285 default_surface_ydata (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
286 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
287 Matrix m (3, 3, 0.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
288 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:
18711
diff
changeset
|
289 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:
18711
diff
changeset
|
290 m(row,col) = row+1; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
291 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
292 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
293 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
294 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
295 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
296 default_surface_zdata (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
297 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
298 Matrix m (3, 3, 0.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
299 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:
18711
diff
changeset
|
300 m(row,row) = 1.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
301 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
302 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
303 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
304 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
305 default_surface_cdata (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
306 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
307 return default_surface_zdata (); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
308 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
309 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
310 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
311 default_patch_faces (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
312 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
313 Matrix m (1, 3, 1.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
314 m(1) = 2.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
315 m(2) = 3.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
316 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
317 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
318 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
319 static Matrix |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
320 default_patch_vertices (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
321 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
322 Matrix m (3, 2, 0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
323 m(1) = 1.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
324 m(3) = 1.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
325 m(4) = 1.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
326 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
327 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
328 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
329 static Matrix |
19091
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
330 default_patch_xdata (void) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
331 { |
19095
82773ee8119a
Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19091
diff
changeset
|
332 Matrix m (3, 1, 0.0); |
19091
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
333 m(1) = 1.0; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
334 return m; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
335 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
336 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
337 static Matrix |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
338 default_patch_ydata (void) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
339 { |
19095
82773ee8119a
Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19091
diff
changeset
|
340 Matrix m (3, 1, 1.0); |
82773ee8119a
Fix ambiguous Matrix initialization from csetdf972b9d080a
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19091
diff
changeset
|
341 m(2) = 0.0; |
19091
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
342 return m; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
343 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
344 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
345 static Matrix |
7427 | 346 default_axes_position (void) |
347 { | |
348 Matrix m (1, 4, 0.0); | |
349 m(0) = 0.13; | |
350 m(1) = 0.11; | |
351 m(2) = 0.775; | |
352 m(3) = 0.815; | |
353 return m; | |
354 } | |
355 | |
356 static Matrix | |
357 default_axes_outerposition (void) | |
358 { | |
359 Matrix m (1, 4, 0.0); | |
360 m(2) = m(3) = 1.0; | |
361 return m; | |
362 } | |
363 | |
7445 | 364 static Matrix |
18801
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
365 default_axes_view (void) |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
366 { |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
367 Matrix m (1, 2, 0.0); |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
368 m(1) = 90.0; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
369 return m; |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
370 } |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
371 |
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
372 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
373 default_axes_tick (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
374 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
375 Matrix m (1, 6, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
376 m(0) = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
377 m(1) = 0.2; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
378 m(2) = 0.4; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
379 m(3) = 0.6; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
380 m(4) = 0.8; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
381 m(5) = 1.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
382 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
383 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
384 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
385 static Matrix |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
386 default_axes_ticklength (void) |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
387 { |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
388 Matrix m (1, 2, 0.0); |
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
389 m(0) = 0.01; |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
390 m(1) = 0.025; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
391 return m; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
392 } |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
393 |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
394 static Matrix |
7445 | 395 default_figure_position (void) |
396 { | |
397 Matrix m (1, 4, 0.0); | |
398 m(0) = 300; | |
399 m(1) = 200; | |
400 m(2) = 560; | |
401 m(3) = 420; | |
402 return m; | |
403 } | |
404 | |
7427 | 405 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
406 default_figure_papersize (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
407 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
408 Matrix m (1, 2, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
409 m(0) = 8.5; |
8961
6b87f2f34fdd
graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents:
8944
diff
changeset
|
410 m(1) = 11.0; |
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 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
415 default_figure_paperposition (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
416 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
417 Matrix m (1, 4, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
418 m(0) = 0.25; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
419 m(1) = 2.50; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
420 m(2) = 8.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
421 m(3) = 6.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
422 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
423 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
424 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
425 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
|
426 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
|
427 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
428 Matrix retval (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
429 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
430 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
|
431 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
|
432 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
|
433 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
|
434 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
435 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
436 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
437 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
438 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
439 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
|
440 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
441 Matrix retval (1, 2, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
442 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
443 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
|
444 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
|
445 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
446 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
447 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
448 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
449 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
450 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
|
451 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
452 Matrix retval (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
453 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
454 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
|
455 retval(1) = 0; |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
456 retval(2) = 0.5; |
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
457 retval(3) = 0.5; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
458 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
459 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
460 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
461 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
462 static double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
463 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
|
464 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
|
465 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
466 // 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
|
467 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
468 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
|
469 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
|
470 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
471 // 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
|
472 // <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
|
473 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
474 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
|
475 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
|
476 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
477 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
|
478 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
|
479 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
480 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
481 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
|
482 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
483 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
|
484 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
|
485 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
|
486 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
|
487 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
|
488 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
|
489 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
|
490 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
|
491 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
492 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
493 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
|
494 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
495 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
|
496 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
|
497 else |
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 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
|
500 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
|
501 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
502 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
|
503 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
|
504 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
|
505 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
|
506 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
|
507 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
|
508 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
|
509 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
510 // 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
|
511 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
512 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
|
513 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
|
514 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
515 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
516 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
517 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
|
518 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
519 |
13804
4f112bebd474
use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents:
13801
diff
changeset
|
520 static Matrix |
7427 | 521 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
|
522 const caseless_str& to_units, const Matrix& parent_dim) |
7427 | 523 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
524 Matrix retval (1, pos.numel ()); |
7427 | 525 double res = 0; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
526 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
|
527 bool is_2d = (pos.numel () == 2); |
7427 | 528 |
529 if (from_units.compare ("pixels")) | |
530 retval = pos; | |
531 else if (from_units.compare ("normalized")) | |
532 { | |
533 retval(0) = pos(0) * parent_dim(0) + 1; | |
534 retval(1) = pos(1) * parent_dim(1) + 1; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
535 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
536 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
537 retval(2) = pos(2) * parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
538 retval(3) = pos(3) * parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
539 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
540 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
541 retval(2) = 0; |
7427 | 542 } |
543 else if (from_units.compare ("characters")) | |
544 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
545 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
546 res = xget (0, "screenpixelsperinch").double_value (); |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
547 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
548 double f = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
549 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
550 // FIXME: this assumes the system font is Helvetica 10pt |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
551 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
552 f = 12.0 * res / 74.951; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
553 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
554 if (f > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
555 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
556 retval(0) = 0.5 * pos(0) * f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
557 retval(1) = pos(1) * f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
558 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
559 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
560 retval(2) = 0.5 * pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
561 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
562 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
563 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
564 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
565 } |
7427 | 566 } |
567 else | |
568 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
569 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
570 res = xget (0, "screenpixelsperinch").double_value (); |
7427 | 571 |
572 double f = 0.0; | |
573 | |
574 if (from_units.compare ("points")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
575 f = res / 72.0; |
7427 | 576 else if (from_units.compare ("inches")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
577 f = res; |
7427 | 578 else if (from_units.compare ("centimeters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
579 f = res / 2.54; |
7427 | 580 |
581 if (f > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
582 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
583 retval(0) = pos(0) * f + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
584 retval(1) = pos(1) * f + 1; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
585 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
586 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
587 retval(2) = pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
588 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
589 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
590 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
591 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
592 } |
7427 | 593 } |
594 | |
595 if (! to_units.compare ("pixels")) | |
596 { | |
597 if (to_units.compare ("normalized")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
598 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
599 retval(0) = (retval(0) - 1) / parent_dim(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
600 retval(1) = (retval(1) - 1) / parent_dim(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
601 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
602 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
603 retval(2) /= parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
604 retval(3) /= parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
605 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
606 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
607 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
608 } |
7427 | 609 else if (to_units.compare ("characters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
610 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
611 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
612 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
613 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
614 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
615 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
616 f = 12.0 * res / 74.951; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
617 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
618 if (f > 0) |
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) = 2 * retval(0) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
621 retval(1) = retval(1) / f; |
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) = 2 * retval(2) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
625 retval(3) = retval(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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
630 } |
7427 | 631 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
632 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
633 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
634 res = xget (0, "screenpixelsperinch").double_value (); |
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 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
637 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
638 if (to_units.compare ("points")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
639 f = res / 72.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
640 else if (to_units.compare ("inches")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
641 f = res; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
642 else if (to_units.compare ("centimeters")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
643 f = res / 2.54; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
644 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
645 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
646 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
647 retval(0) = (retval(0) - 1) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
648 retval(1) = (retval(1) - 1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
649 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
650 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
651 retval(2) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
652 retval(3) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
653 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
654 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
655 retval(2) = 0; |
10315
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 } |
7427 | 658 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
659 else if (! is_rectangle && ! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
660 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
661 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
662 return retval; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
663 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
664 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
665 static Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
666 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
|
667 const caseless_str& from_units, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
668 const caseless_str& to_units) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
669 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
670 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
|
671 graphics_object ax = go.get_ancestor ("axes"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
672 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
673 Matrix retval; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
674 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
675 if (ax.valid_object ()) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
676 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
677 const axes::properties& ax_props = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
678 dynamic_cast<const axes::properties&> (ax.get_properties ()); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
679 graphics_xform ax_xform = ax_props.get_transform (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
680 bool is_rectangle = (pos.numel () == 4); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
681 Matrix ax_bbox = ax_props.get_boundingbox (true), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
682 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
|
683 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
684 if (from_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
685 { |
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 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
|
689 v2 = ax_xform.transform (pos(0) + pos(2), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
690 pos(1) + pos(3), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
691 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
692 retval.resize (1, 4); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
693 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
694 retval(0) = v1(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
695 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
|
696 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
697 retval(3) = v1(1) - v2(1); |
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 else |
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 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
|
702 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
703 retval.resize (1, 3); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
704 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
705 retval(0) = v(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
706 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
|
707 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
708 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
709 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
710 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
711 retval = convert_position (pos, from_units, "pixels", ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
712 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
713 if (! to_units.compare ("pixels")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
714 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
715 if (to_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
716 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
717 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
718 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
719 ColumnVector v1, v2; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
720 v1 = ax_xform.untransform ( |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
721 retval(0) + ax_bbox(0) - 1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
722 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
|
723 v2 = ax_xform.untransform ( |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
724 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
|
725 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
|
726 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
727 retval.resize (1, 4); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
728 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
729 retval(0) = v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
730 retval(1) = v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
731 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
732 retval(3) = v2(1) - v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
733 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
734 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
735 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
736 ColumnVector v; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
737 v = ax_xform.untransform ( |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
738 retval(0) + ax_bbox(0) - 1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
739 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
|
740 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
741 retval.resize (1, 3); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
742 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
743 retval(0) = v(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
744 retval(1) = v(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
745 retval(2) = v(2); |
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 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
748 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
749 retval = convert_position (retval, "pixels", to_units, ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
750 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
751 } |
7427 | 752 |
753 return retval; | |
754 } | |
755 | |
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
|
756 // 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
|
757 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
|
758 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
|
759 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
760 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
|
761 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
|
762 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
|
763 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
|
764 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
765 |
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
|
766 static void |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
767 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
|
768 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
|
769 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
|
770 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
771 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
|
772 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0)); |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
773 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
|
774 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
|
775 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
776 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
|
777 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
778 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
|
779 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
|
780 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
|
781 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
782 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
|
783 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
784 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
|
785 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
|
786 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
|
787 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
|
788 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
789 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
|
790 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
791 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
|
792 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
|
793 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
|
794 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
795 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
796 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
797 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
|
798 void |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
799 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
|
800 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
|
801 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
|
802 { |
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 for (octave_idx_type i = 0; i < lda; i++) |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
804 convert_cdata_2 (is_scaled, is_real, |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
805 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
|
806 } |
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 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
808 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
809 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
|
810 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
|
811 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
812 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
|
813 |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
814 // 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
|
815 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
|
816 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
817 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
818 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
|
819 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
|
820 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
821 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
|
822 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
|
823 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
824 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
825 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
826 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
|
827 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
828 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
829 cmap = _cmap; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
830 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
831 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
832 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
833 { |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
834 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
|
835 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
836 if (ax.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
837 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
838 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
|
839 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
840 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
841 clim = _clim; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
842 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
843 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
844 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
845 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
846 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
847 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
848 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
849 |
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
|
850 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
|
851 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
|
852 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
853 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
|
854 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
|
855 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
856 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
|
857 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
|
858 |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
859 // 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:
18835
diff
changeset
|
860 // 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:
18835
diff
changeset
|
861 // 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:
18835
diff
changeset
|
862 // 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:
18835
diff
changeset
|
863 // 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:
18835
diff
changeset
|
864 // 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:
18835
diff
changeset
|
865 // 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:
18835
diff
changeset
|
866 |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
867 #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
|
868 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
|
869 { \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
870 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
|
871 \ |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
872 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
|
873 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
|
874 } \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
875 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
|
876 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
877 if (cdata.is_uint8_type ()) |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
878 CONVERT_CDATA_1 (uint8NDArray, uint8_, false); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
879 else if (cdata.is_uint16_type ()) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
880 CONVERT_CDATA_1 (uint16NDArray, uint16_, false); |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
881 else if (cdata.is_double_type ()) |
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
882 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
|
883 else if (cdata.is_single_type ()) |
18838
44f0d1a53ead
Add support for integer data types for image cdata.
Rik <rik@octave.org>
parents:
18835
diff
changeset
|
884 CONVERT_CDATA_1 (FloatNDArray, float_, true); |
18877
d57a83f2d73e
Preserve image class in cdata (bug #41240).
Rik <rik@octave.org>
parents:
18857
diff
changeset
|
885 else if (cdata.is_bool_type ()) |
d57a83f2d73e
Preserve image class in cdata (bug #41240).
Rik <rik@octave.org>
parents:
18857
diff
changeset
|
886 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
|
887 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
|
888 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
|
889 |
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 #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
|
891 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
892 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
893 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
894 |
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
|
895 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
|
896 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
|
897 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
|
898 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
|
899 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
900 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
|
901 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
|
902 |
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
|
903 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
|
904 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
905 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
|
906 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
907 // 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
|
908 if (! xisinf (e)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
909 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
910 if (e < emin) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
911 emin = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
912 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
913 if (e > emax) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
914 emax = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
915 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
916 if (e > 0 && e < eminp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
917 eminp = e; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
918 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
919 if (e < 0 && e > emaxp) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
920 emaxp = e; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
921 } |
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
|
922 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
923 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
924 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
925 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
926 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
|
927 caseless_str& rest) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
928 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
929 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
930 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
931 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
932 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
933 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
934 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
935 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
936 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
937 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
938 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
939 offset = 4; |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
940 else if (len >= 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
941 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
942 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
943 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
944 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
945 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
946 else if (len >= 6) |
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 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
949 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
950 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
951 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
952 else if (len >= 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
953 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
954 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
955 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
956 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
|
957 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
958 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
|
959 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
|
960 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
961 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
|
962 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
963 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
964 || 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
|
965 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
966 else if (len >= 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
967 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
968 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
|
969 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
970 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
971 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
972 else if (len >= 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
973 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
974 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
|
975 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
976 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
977 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
978 else if (len >= 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
979 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
980 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
|
981 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
982 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
983 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
984 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
985 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
986 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
987 } |
10315
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
990 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
991 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
992 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
993 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
994 go_name = pfx; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
995 rest = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
996 result = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
997 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
998 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
999 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1000 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1001 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1002 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1003 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1004 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
|
1005 const graphics_handle& h = graphics_handle (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1006 const graphics_handle& p = graphics_handle ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1007 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1008 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1009 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1010 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1011 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1012 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1013 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1014 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1015 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1016 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1017 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1018 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1019 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1020 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1021 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1022 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1023 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
1024 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
1025 go = new hggroup (h, p); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1026 else if (type.compare ("uimenu")) |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1027 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
|
1028 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
|
1029 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
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 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
|
1035 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
|
1036 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
|
1037 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
|
1038 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
|
1039 go = new uitoggletool (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1040 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1041 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1042 |
6406 | 1043 // --------------------------------------------------------------------- |
1044 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1045 bool |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1046 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
|
1047 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1048 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1049 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1050 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1051 // 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
|
1052 if (id >= 0 && do_notify_toolkit) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1053 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1054 graphics_object go = gh_manager::get_object (parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1055 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
|
1056 go.update (id); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1057 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1058 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1059 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1060 if (do_run && ! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1061 run_listeners (POSTSET); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1062 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1063 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1064 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1065 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1066 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1067 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1068 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1069 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1070 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1071 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
|
1072 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1073 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
|
1074 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1075 for (int i = 0; i < l.length (); i++) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1076 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1077 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
|
1078 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1079 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1080 break; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1081 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1082 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1083 |
6705 | 1084 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
|
1085 : default_val (), possible_vals () |
6406 | 1086 { |
6705 | 1087 size_t beg = 0; |
1088 size_t len = opt_string.length (); | |
1089 bool done = len == 0; | |
6681 | 1090 |
6705 | 1091 while (! done) |
1092 { | |
1093 size_t end = opt_string.find ('|', beg); | |
6681 | 1094 |
6705 | 1095 if (end == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1096 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1097 end = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1098 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1099 } |
6681 | 1100 |
6705 | 1101 std::string t = opt_string.substr (beg, end-beg); |
6681 | 1102 |
6705 | 1103 // Might want more error checking here... |
1104 if (t[0] == '{') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1105 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1106 t = t.substr (1, t.length () - 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1107 default_val = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1108 } |
6705 | 1109 else if (beg == 0) // ensure default value |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1110 default_val = t; |
6681 | 1111 |
6705 | 1112 possible_vals.insert (t); |
6681 | 1113 |
6705 | 1114 beg = end + 1; |
1115 } | |
1116 } | |
6681 | 1117 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1118 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1119 radio_values::values_as_string (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1120 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1121 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1122 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
|
1123 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1124 { |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1125 if (retval.empty ()) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1126 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1127 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1128 retval = "{" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1129 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1130 retval = *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1131 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1132 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1133 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1134 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1135 retval += " | {" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1136 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1137 retval += " | " + *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1138 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1139 } |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1140 |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1141 if (! retval.empty ()) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1142 retval = "[ " + retval + " ]"; |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1143 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1144 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1145 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1146 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1147 Cell |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1148 radio_values::values_as_cell (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 octave_idx_type i = 0; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1151 Cell retval (nelem (), 1); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1152 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
|
1153 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1154 retval(i++) = std::string (*it); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1155 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1156 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1157 |
6705 | 1158 bool |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1159 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
|
1160 { |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1161 bool retval = true; |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1162 |
6705 | 1163 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
|
1164 |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
1165 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
|
1166 unsigned int len = str.length (); |
6681 | 1167 |
6925 | 1168 std::transform (str.begin (), str.end (), str.begin (), tolower); |
1169 | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1170 if (str.compare (0, len, "blue", 0, len) == 0) |
6761 | 1171 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
|
1172 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
|
1173 || str.compare (0, len, "k", 0, len) == 0) |
6761 | 1174 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
|
1175 else if (str.compare (0, len, "red", 0, len) == 0) |
6761 | 1176 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
|
1177 else if (str.compare (0, len, "green", 0, len) == 0) |
6761 | 1178 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
|
1179 else if (str.compare (0, len, "yellow", 0, len) == 0) |
6761 | 1180 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
|
1181 else if (str.compare (0, len, "magenta", 0, len) == 0) |
6761 | 1182 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
|
1183 else if (str.compare (0, len, "cyan", 0, len) == 0) |
6761 | 1184 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
|
1185 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
|
1186 || str.compare (0, len, "w", 0, len) == 0) |
6761 | 1187 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
|
1188 else |
6761 | 1189 retval = false; |
6406 | 1190 |
6705 | 1191 if (retval) |
1192 { | |
1193 for (int i = 0; i < 3; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1194 xrgb(i) = tmp_rgb[i]; |
6705 | 1195 } |
6563 | 1196 |
6705 | 1197 return retval; |
1198 } | |
6681 | 1199 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1200 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1201 color_property::do_set (const octave_value& val) |
6790 | 1202 { |
1203 if (val.is_string ()) | |
1204 { | |
1205 std::string s = val.string_value (); | |
1206 | |
1207 if (! s.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1208 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1209 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1210 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1211 if (radio_val.contains (s, match)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1212 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1213 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
|
1214 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1215 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
|
1216 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
|
1217 "%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
|
1218 "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
|
1219 match.c_str ()); |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1220 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1221 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1222 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1223 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1224 } |
6790 | 1225 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1226 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1227 color_values col (s); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1228 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1229 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1230 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1231 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1232 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1233 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1234 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1235 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1236 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1237 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1238 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
|
1239 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
|
1240 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1241 } |
6790 | 1242 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1243 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
|
1244 get_name ().c_str ()); |
6790 | 1245 } |
9311
868fbeb2e365
allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents:
9238
diff
changeset
|
1246 else if (val.is_numeric_type ()) |
6790 | 1247 { |
1248 Matrix m = val.matrix_value (); | |
1249 | |
1250 if (m.numel () == 3) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1251 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
1252 color_values col (m(0), m(1), m(2)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1253 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1254 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1255 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1256 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1257 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1258 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1259 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1260 } |
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 } |
6790 | 1263 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1264 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
|
1265 get_name ().c_str ()); |
6790 | 1266 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1267 else |
7363 | 1268 error ("invalid value for color property \"%s\"", |
1269 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1270 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1271 return false; |
6790 | 1272 } |
1273 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1274 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1275 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
|
1276 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1277 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1278 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1279 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
|
1280 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1281 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1282 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
|
1283 { |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1284 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
|
1285 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1286 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
|
1287 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
|
1288 "%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
|
1289 "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
|
1290 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
|
1291 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1292 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1293 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1294 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1295 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1296 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1297 error ("invalid value for double_radio property \"%s\"", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1298 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
|
1299 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1300 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
|
1301 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1302 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1303 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1304 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
|
1305 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1306 dval = new_dval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1307 current_type = double_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1308 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1309 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1310 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1311 else |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1312 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
|
1313 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1314 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1315 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1316 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1317 |
7363 | 1318 bool |
1319 array_property::validate (const octave_value& v) | |
1320 { | |
7364 | 1321 bool xok = false; |
7363 | 1322 |
1323 // check value type | |
1324 if (type_constraints.size () > 0) | |
1325 { | |
17631
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1326 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
|
1327 xok = true; |
7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15017
diff
changeset
|
1328 |
7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15017
diff
changeset
|
1329 // 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
|
1330 // 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
|
1331 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
|
1332 && v.is_complex_type ()) |
7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
15017
diff
changeset
|
1333 xok = false; |
7363 | 1334 } |
1335 else | |
9181
86ae7e50dc5d
graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
1336 xok = v.is_numeric_type (); |
7363 | 1337 |
7364 | 1338 if (xok) |
7363 | 1339 { |
17631
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1340 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
|
1341 return true; |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1342 |
7363 | 1343 dim_vector vdims = v.dims (); |
1344 int vlen = vdims.length (); | |
1345 | |
7364 | 1346 xok = false; |
7363 | 1347 |
17631
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1348 // 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
|
1349 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); |
18801
2deed6538c72
Make some graphics factory defaults conform to Matlab values (bug #41770).
pantxo <pantxo.diribarne@gmail.com>
parents:
18711
diff
changeset
|
1350 ! 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
|
1351 { |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1352 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
|
1353 |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1354 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
|
1355 { |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1356 xok = true; |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1357 |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1358 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
|
1359 { |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1360 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
|
1361 { |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1362 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
|
1363 xok = false; |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1364 } |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1365 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
|
1366 break; |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1367 } |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1368 } |
94dd9bba06a0
Fix validation of array properties to set(), avoid segfaults (bug #bug #35687).
Rik <rik@octave.org>
parents:
17626
diff
changeset
|
1369 } |
7363 | 1370 } |
1371 | |
7364 | 1372 return xok; |
7363 | 1373 } |
1374 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1375 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1376 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1377 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1378 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1379 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1380 if (data.dims () == v.dims ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1381 { |
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
|
1382 |
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
|
1383 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1384 { \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1385 if (data.numel () == 1) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1386 return data.F ## scalar_value () == \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1387 v.F ## scalar_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1388 else \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1389 { \ |
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
|
1390 /* 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
|
1391 /* that are converted, to not be deallocated early */ \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1392 const A m1 = data.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1393 const T* d1 = m1.data (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1394 const A m2 = v.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1395 const T* d2 = m2.data ();\ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1396 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1397 bool flag = true; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1398 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1399 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
|
1400 if (d1[i] != d2[i]) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1401 flag = false; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1402 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1403 return flag; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1404 } \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1405 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1406 |
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
|
1407 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
|
1408 CHECK_ARRAY_EQUAL (double, , NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1409 else if (data.is_single_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1410 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1411 else if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1412 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1413 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1414 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1415 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1416 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1417 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1418 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1419 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1420 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1421 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1422 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1423 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1424 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1425 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1426 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1427 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1428 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1429 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1430 return false; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1431 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1432 |
7363 | 1433 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
|
1434 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
|
1435 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1436 xmin = xminp = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1437 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
|
1438 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1439 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
|
1440 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1441 if (data.is_integer_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1442 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1443 if (data.is_int8_type ()) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1444 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
|
1445 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1446 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
|
1447 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
|
1448 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1449 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
|
1450 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
|
1451 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1452 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
|
1453 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
|
1454 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1455 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
|
1456 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
|
1457 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1458 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
|
1459 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
|
1460 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1461 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
|
1462 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
|
1463 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1464 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
|
1465 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
|
1466 xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1467 } |
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
|
1468 else |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1469 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
|
1470 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1471 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1472 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1473 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1474 handle_property::do_set (const octave_value& v) |
7363 | 1475 { |
1476 double dv = v.double_value (); | |
1477 | |
1478 if (! error_state) | |
1479 { | |
1480 graphics_handle gh = gh_manager::lookup (dv); | |
1481 | |
1482 if (xisnan (gh.value ()) || gh.ok ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1483 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1484 if (current_val != gh) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1485 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1486 current_val = gh; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1487 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1488 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1489 } |
7363 | 1490 else |
1491 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
|
1492 dv, get_name ().c_str ()); |
7363 | 1493 } |
1494 else | |
1495 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
|
1496 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1497 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1498 return false; |
7363 | 1499 } |
1500 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1501 Matrix |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1502 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
|
1503 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1504 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
|
1505 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
|
1506 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1507 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
|
1508 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1509 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
|
1510 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
|
1511 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1512 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
|
1513 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1514 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
|
1515 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
|
1516 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1517 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
|
1518 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1519 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
|
1520 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1521 if (! return_hidden) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1522 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1523 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1524 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
|
1525 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1526 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1527 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1528 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
|
1529 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1530 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1531 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1532 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
|
1533 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
|
1534 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1535 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1536 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1537 return retval; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1538 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1539 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1540 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1541 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
|
1542 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1543 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
|
1544 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
|
1545 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1546 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
|
1547 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1548 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
|
1549 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
|
1550 |
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 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1553 if (clear) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1554 children_list.clear (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1555 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1556 |
7363 | 1557 bool |
7367 | 1558 callback_property::validate (const octave_value& v) const |
7363 | 1559 { |
7367 | 1560 // case 1: function handle |
1561 // case 2: cell array with first element being a function handle | |
1562 // case 3: string corresponding to known function name | |
1563 // case 4: evaluatable string | |
1564 // case 5: empty matrix | |
1565 | |
1566 if (v.is_function_handle ()) | |
1567 return true; | |
1568 else if (v.is_string ()) | |
1569 // complete validation will be done at execution-time | |
1570 return true; | |
1571 else if (v.is_cell () && v.length () > 0 | |
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
|
1572 && (v.rows () == 1 || v.columns () == 1) |
7367 | 1573 && v.cell_value ()(0).is_function_handle ()) |
1574 return true; | |
1575 else if (v.is_empty ()) | |
1576 return true; | |
1577 | |
1578 return false; | |
7363 | 1579 } |
1580 | |
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
|
1581 // If TRUE, we are executing any callback function, or the functions it |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1582 // calls. Used to determine handle visibility inside 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
|
1583 // functions. |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1584 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
|
1585 |
7363 | 1586 void |
7367 | 1587 callback_property::execute (const octave_value& data) const |
7363 | 1588 { |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1589 unwind_protect frame; |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1590 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1591 // 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
|
1592 // 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
|
1593 // callback routines. |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1594 frame.protect_var (executing); |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1595 |
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
|
1596 // 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
|
1597 // 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
|
1598 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
|
1599 |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1600 if (! executing) |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1601 { |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1602 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
|
1603 executing_callback = true; |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1604 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1605 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
|
1606 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
|
1607 } |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1608 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1609 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1610 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1611 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1612 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
|
1613 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1614 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1615 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
|
1616 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
|
1617 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1618 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1619 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1620 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1621 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1622 std::string val = (args.length () > 0 ? args(0).string_value () : ""); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1623 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1624 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1625 retval = property (new string_property (name, h, val)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1626 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1627 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1628 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1629 octave_value val = args.length () > 0 ? args(0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1630 : octave_value (Matrix ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1631 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1632 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1633 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1634 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1635 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1636 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1637 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1638 std::string vals = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1639 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1640 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1641 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1642 retval = property (new radio_property (name, h, vals)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1643 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1644 if (args.length () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1645 retval.set (args(1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1646 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1647 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1648 error ("addproperty: invalid argument for radio property, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1649 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1650 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1651 error ("addproperty: missing possible values for radio property"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1652 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1653 else if (type.compare ("double")) |
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 double d = (args.length () > 0 ? args(0).double_value () : 0); |
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 (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1658 retval = property (new double_property (name, h, d)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1659 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1660 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1661 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1662 double hh = (args.length () > 0 ? args(0).double_value () : octave_NaN); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1663 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1664 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1665 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1666 graphics_handle gh (hh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1667 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1668 retval = property (new handle_property (name, h, gh)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1669 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1670 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1671 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1672 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1673 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1674 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1675 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1676 retval.set (args(0)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1677 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1678 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1679 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1680 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1681 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1682 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1683 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1684 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1685 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1686 // FIXME: additional argument could define constraints, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1687 // but is this really useful? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1688 } |
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 ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1691 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1692 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1693 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1694 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1695 if (args.length () > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1696 rv = radio_values (args(1).string_value ()); |
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 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1699 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1700 retval = property (new color_property (name, h, cv, rv)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1701 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1702 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1703 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1704 if (args.length () > 0 && ! args(0).is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1705 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1706 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1707 retval.set (rv.default_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1708 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1709 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1710 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1711 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1712 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1713 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1714 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1715 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
|
1716 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1717 graphics_object go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1718 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1719 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
|
1720 dprop_obj_map.find (go_name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1721 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1722 if (it == dprop_obj_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1723 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1724 base_graphics_object *bgo = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1725 make_graphics_object_from_type (go_name); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1726 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1727 if (bgo) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1728 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1729 go = graphics_object (bgo); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1730 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1731 dprop_obj_map[go_name] = go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1732 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1733 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1734 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1735 go = it->second; |
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 if (go.valid_object ()) |
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 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
|
1740 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1741 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1742 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1743 retval = prop.clone (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1744 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1745 retval.set_parent (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1746 retval.set_name (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1747 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1748 if (args.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1749 retval.set (args(0)); |
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1752 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1753 error ("addproperty: invalid object type (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1754 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1755 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1756 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1757 error ("addproperty: unsupported type for dynamic property (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1758 type.c_str ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1759 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1760 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1761 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1762 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1763 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1764 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1765 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
|
1766 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1767 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
|
1768 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1769 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1770 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1771 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
|
1772 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1773 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
|
1774 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
|
1775 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1776 go.finalize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1777 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1778 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1779 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1780 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1781 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
|
1782 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1783 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
|
1784 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1785 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1786 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1787 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
|
1788 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1789 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1790 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1791 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
|
1792 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
|
1793 } |
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 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1797 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
|
1798 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1799 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1800 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
|
1801 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1802 toolkit = b; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1803 __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
|
1804 __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
|
1805 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1806 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1807 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
|
1808 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1809 mark_modified (); |
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 |
7363 | 1812 // --------------------------------------------------------------------- |
6681 | 1813 |
6705 | 1814 void |
7189 | 1815 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1816 { |
6705 | 1817 size_t offset = 0; |
6681 | 1818 |
6705 | 1819 size_t len = name.length (); |
6681 | 1820 |
6705 | 1821 if (len > 4) |
1822 { | |
7189 | 1823 caseless_str pfx = name.substr (0, 4); |
6681 | 1824 |
6705 | 1825 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1826 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1827 offset = 4; |
6705 | 1828 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1829 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1830 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1831 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1832 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1833 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1834 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1835 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1836 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1837 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1838 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1839 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1840 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1841 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1842 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1843 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1844 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
|
1845 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1846 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
|
1847 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
|
1848 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1849 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
|
1850 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1851 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1852 || 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
|
1853 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1854 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1855 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1856 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
|
1857 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1858 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1859 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1860 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1861 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1862 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
|
1863 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1864 if (pfx.compare ("uitoogletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1865 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1866 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1867 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1868 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
|
1869 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1870 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1871 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1872 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1873 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1874 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1875 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1876 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1877 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1878 } |
6681 | 1879 |
6705 | 1880 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1881 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
1882 // 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
|
1883 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1884 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1885 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1886 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
|
1887 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
|
1888 tolower); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1889 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1890 bool has_property = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1891 if (pfx == "axes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1892 has_property = axes::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1893 else if (pfx == "line") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1894 has_property = line::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1895 else if (pfx == "text") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1896 has_property = text::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1897 else if (pfx == "image") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1898 has_property = image::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1899 else if (pfx == "patch") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1900 has_property = patch::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1901 else if (pfx == "figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1902 has_property = figure::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1903 else if (pfx == "surface") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1904 has_property = surface::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1905 else if (pfx == "hggroup") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1906 has_property = hggroup::properties::has_core_property (pname); |
11283 | 1907 else if (pfx == "uimenu") |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1908 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
|
1909 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
|
1910 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
|
1911 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
|
1912 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
|
1913 else if (pfx == "uicontextmenu") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1914 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
|
1915 else if (pfx == "uitoolbar") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1916 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
|
1917 else if (pfx == "uipushtool") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1918 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
|
1919 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1920 if (has_property) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1921 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1922 bool remove = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1923 if (val.is_string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1924 { |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
1925 std::string tval = val.string_value (); |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
1926 |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
1927 remove = (tval.compare ("remove") == 0); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1928 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1929 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1930 pval_map_type& pval_map = plist_map[pfx]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1931 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1932 if (remove) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1933 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1934 pval_map_iterator p = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1935 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1936 if (p != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1937 pval_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1938 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1939 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1940 pval_map[pname] = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1941 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1942 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
1943 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
|
1944 } |
6705 | 1945 } |
6406 | 1946 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
1947 if (! error_state && offset == 0) |
6705 | 1948 error ("invalid default property specification"); |
1949 } | |
6406 | 1950 |
6705 | 1951 octave_value |
7189 | 1952 property_list::lookup (const caseless_str& name) const |
6705 | 1953 { |
1954 octave_value retval; | |
6406 | 1955 |
6705 | 1956 size_t offset = 0; |
6406 | 1957 |
6705 | 1958 size_t len = name.length (); |
6406 | 1959 |
6705 | 1960 if (len > 4) |
1961 { | |
7189 | 1962 caseless_str pfx = name.substr (0, 4); |
6406 | 1963 |
6705 | 1964 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1965 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1966 offset = 4; |
6705 | 1967 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1968 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1969 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1970 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1971 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1972 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1973 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1974 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1975 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1976 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1977 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1978 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1979 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1980 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1981 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1982 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1983 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
|
1984 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1985 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
|
1986 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
|
1987 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1988 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
|
1989 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1990 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1991 || 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
|
1992 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1993 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1994 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1995 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
|
1996 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1997 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1998 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1999 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2000 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2001 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
|
2002 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2003 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2004 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2005 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2006 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2007 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
|
2008 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2009 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2010 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2011 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2012 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
2013 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2014 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2015 } |
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 } |
6406 | 2018 |
6705 | 2019 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2020 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2021 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2022 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2023 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
|
2024 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
|
2025 tolower); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2026 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2027 plist_map_const_iterator p = find (pfx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2028 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2029 if (p != end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2030 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2031 const pval_map_type& pval_map = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2032 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2033 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
|
2034 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2035 if (q != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2036 retval = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2037 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2038 } |
6705 | 2039 } |
6406 | 2040 |
6705 | 2041 return retval; |
2042 } | |
6406 | 2043 |
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
|
2044 octave_scalar_map |
6705 | 2045 property_list::as_struct (const std::string& prefix_arg) const |
2046 { | |
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
|
2047 octave_scalar_map m; |
6406 | 2048 |
6705 | 2049 for (plist_map_const_iterator p = begin (); p != end (); p++) |
2050 { | |
2051 std::string prefix = prefix_arg + p->first; | |
6406 | 2052 |
6705 | 2053 const pval_map_type pval_map = p->second; |
6406 | 2054 |
6705 | 2055 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
|
2056 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2057 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2058 m.assign (prefix + q->first, q->second); |
6705 | 2059 } |
6406 | 2060 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2061 return m; |
6705 | 2062 } |
6432 | 2063 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2064 // 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
|
2065 |
6705 | 2066 void |
2067 graphics_object::set (const octave_value_list& args) | |
2068 { | |
2069 int nargin = args.length (); | |
6406 | 2070 |
6705 | 2071 if (nargin == 0) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2072 error ("graphics_object::set: Nothing to set"); |
6705 | 2073 else if (nargin % 2 == 0) |
2074 { | |
2075 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
|
2076 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2077 caseless_str name = args(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2078 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2079 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2080 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2081 octave_value val = args(i+1); |
6406 | 2082 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2083 set_value_or_default (name, val); |
6406 | 2084 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2085 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2086 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2087 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2088 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2089 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
|
2090 } |
6705 | 2091 } |
2092 else | |
2093 error ("set: invalid number of arguments"); | |
2094 } | |
6406 | 2095 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2096 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2097 ## 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
|
2098 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2099 %! hf = figure ("visible", "off"); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2100 %! 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
|
2101 %! 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
|
2102 %! lw = get (h, "linewidth"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2103 %! mk = get (h, "marker"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2104 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2105 %! assert (lw, 10); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2106 %! assert (mk, "x"); |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2107 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2108 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2109 // 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
|
2110 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2111 graphics_object::set (const Array<std::string>& names, |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2112 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
|
2113 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2114 if (names.numel () != values.columns ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2115 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
2116 error ("set: number of names must match number of value columns (%d != %d)", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2117 names.numel (), values.columns ()); |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2118 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2119 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2120 octave_idx_type k = names.columns (); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2121 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2122 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
|
2123 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2124 caseless_str name = names(column); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2125 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
|
2126 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2127 set_value_or_default (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2128 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2129 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2130 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2131 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2132 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2133 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2134 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2135 ## 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
|
2136 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2137 %! hf = figure ("visible", "off"); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2138 %! 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
|
2139 %! 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
|
2140 %! lw = get (h, "linewidth"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2141 %! mk = get (h, "marker"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2142 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2143 %! assert (lw, 10); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2144 %! assert (mk, "x"); |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2145 |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2146 ## 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
|
2147 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2148 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2149 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2150 %! 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
|
2151 %! 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
|
2152 %! 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
|
2153 %! 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
|
2154 %! 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
|
2155 %! 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
|
2156 %! 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
|
2157 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2158 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2159 %! end_unwind_protect; |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2160 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2161 %!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
|
2162 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2163 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2164 %! 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
|
2165 %! 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
|
2166 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2167 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2168 %! end_unwind_protect |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2169 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2170 %!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
|
2171 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2172 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2173 %! 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
|
2174 %! 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
|
2175 %! unwind_protect_cleanup |
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 %! end_unwind_protect |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2178 */ |
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 // 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
|
2181 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
|
2182 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
|
2183 { |
15760
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2184 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
|
2185 { |
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2186 caseless_str name = m.keys ()[p]; |
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2187 |
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2188 octave_value val = octave_value (m.contents (name).elem (m.numel () - 1)); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2189 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2190 set_value_or_default (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2191 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2192 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2193 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2194 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2195 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2196 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2197 /* |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2198 ## test set ticklabels for compatibility |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2199 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2200 %! hf = figure ("visible", "off"); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2201 %! 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
|
2202 %! 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
|
2203 %! close (hf); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2204 %! assert (class (xticklabel), "char"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2205 %! 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
|
2206 |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2207 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2208 %! hf = figure ("visible", "off"); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2209 %! 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
|
2210 %! 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
|
2211 %! close (hf); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2212 %! assert (class (xticklabel), "char"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2213 %! 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
|
2214 |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2215 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2216 %! hf = figure ("visible", "off"); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2217 %! 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
|
2218 %! 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
|
2219 %! close (hf); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2220 %! assert (class (xticklabel), "char"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2221 %! 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
|
2222 |
16841
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
2223 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2224 %! hf = figure ("visible", "off"); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2225 %! 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
|
2226 %! 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
|
2227 %! close (hf); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2228 %! assert (class (xticklabel), "cell"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
2229 %! assert (size (xticklabel), [6, 1]); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2230 */ |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2231 |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
2232 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2233 ## 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
|
2234 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2235 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2236 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2237 %! 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
|
2238 %! 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
|
2239 %! 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
|
2240 %! 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
|
2241 %! 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
|
2242 %! 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
|
2243 %! 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
|
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 |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2247 |
15760
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2248 ## test ordering |
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2249 %!test |
1ac3c906990a
graphics.cc (graphics_object::set (const octave_map& m)): set structure
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
15707
diff
changeset
|
2250 %! 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
|
2251 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2252 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2253 %! h = line (); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2254 %! set (h, "userdata", {}); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2255 %! 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
|
2256 %! 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
|
2257 %! ## "linewidth" first |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2258 %! props.linewidth = 2; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2259 %! props.color = "r"; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2260 %! set (h, props); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2261 %! 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
|
2262 %! clear props; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2263 %! clf (); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2264 %! h = line (); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2265 %! set (h, "userdata", {}); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2266 %! 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
|
2267 %! 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
|
2268 %! ## "color" first |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2269 %! props.color = "r"; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2270 %! props.linewidth = 2; |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2271 %! set (h, props); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2272 %! 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
|
2273 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2274 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
2275 %! end_unwind_protect |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2276 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2277 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2278 // 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
|
2279 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2280 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2281 graphics_object::set_value_or_default (const caseless_str& name, |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2282 const octave_value& val) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2283 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2284 if (val.is_string ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2285 { |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2286 std::string tval = val.string_value (); |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2287 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2288 octave_value default_val; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2289 |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2290 if (tval.compare ("default") == 0) |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2291 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2292 default_val = get_default (name); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2293 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2294 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2295 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2296 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2297 rep->set (name, default_val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2298 } |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2299 else if (tval.compare ("factory") == 0) |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2300 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2301 default_val = get_factory_default (name); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2302 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2303 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2304 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2305 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2306 rep->set (name, default_val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2307 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2308 else |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2309 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2310 // Matlab specifically uses "\default" to escape string setting |
16312
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2311 if (tval.compare ("\\default") == 0) |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2312 rep->set (name, "default"); |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2313 else if (tval.compare ("\\factory") == 0) |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2314 rep->set (name, "factory"); |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2315 else |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2316 rep->set (name, val); |
d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
Rik <rik@octave.org>
parents:
16206
diff
changeset
|
2317 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2318 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2319 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2320 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2321 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2322 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2323 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
2324 ## 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
|
2325 %!test |
17237
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2326 %! old_lw = get (0, "defaultlinelinewidth"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2327 %! unwind_protect |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2328 %! hf = figure ("visible", "off"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2329 %! h = plot (1:10, 10:-1:1); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2330 %! set (0, "defaultlinelinewidth", 20); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2331 %! set (h, "linewidth", "default"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2332 %! assert (get (h, "linewidth"), 20); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2333 %! set (h, "linewidth", "factory"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2334 %! assert (get (h, "linewidth"), 0.5); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2335 %! unwind_protect_cleanup |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2336 %! close (hf); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2337 %! set (0, "defaultlinelinewidth", old_lw); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
2338 %! end_unwind_protect |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2339 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2340 |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2341 static double |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2342 make_handle_fraction (void) |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2343 { |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2344 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
|
2345 |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2346 return (rand () + 1.0) / maxrand; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2347 } |
6406 | 2348 |
6705 | 2349 graphics_handle |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2350 gh_manager::do_get_handle (bool integer_figure_handle) |
6705 | 2351 { |
2352 graphics_handle retval; | |
6406 | 2353 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
2354 if (integer_figure_handle) |
6705 | 2355 { |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2356 // Figure handles are positive integers corresponding to the |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2357 // figure number. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2358 |
6705 | 2359 // We always want the lowest unused figure number. |
6406 | 2360 |
6705 | 2361 retval = 1; |
6425 | 2362 |
6705 | 2363 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
|
2364 retval++; |
6705 | 2365 } |
2366 else | |
2367 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2368 // Other graphics handles are negative integers plus some random |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2369 // fractional part. To avoid running out of integers, we |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2370 // recycle the integer part but tack on a new random part each |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2371 // time. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2372 |
6705 | 2373 free_list_iterator p = handle_free_list.begin (); |
6406 | 2374 |
6705 | 2375 if (p != handle_free_list.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2376 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2377 retval = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2378 handle_free_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2379 } |
6705 | 2380 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2381 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2382 retval = graphics_handle (next_handle); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2383 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
2384 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
|
2385 } |
6705 | 2386 } |
6406 | 2387 |
6705 | 2388 return retval; |
2389 } | |
6406 | 2390 |
6705 | 2391 void |
2392 gh_manager::do_free (const graphics_handle& h) | |
2393 { | |
7056 | 2394 if (h.ok ()) |
6705 | 2395 { |
6874 | 2396 if (h.value () != 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2397 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2398 iterator p = handle_map.find (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2399 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2400 if (p != handle_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2401 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2402 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
|
2403 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2404 bp.set_beingdeleted (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2405 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2406 bp.delete_children (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2407 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2408 octave_value val = bp.get_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2409 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2410 bp.execute_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2411 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2412 // 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
|
2413 p->second.finalize (); |
8208 | 2414 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2415 // Note: this will be valid only for first explicitly |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2416 // deleted 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
|
2417 // unknown graphics toolkit. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2418 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2419 // Graphics handles for non-figure objects are negative |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2420 // integers plus some random fractional part. To avoid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2421 // 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
|
2422 // 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
|
2423 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2424 handle_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2425 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2426 if (h.value () < 0) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2427 handle_free_list.insert |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2428 (std::ceil (h.value ()) - make_handle_fraction ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2429 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2430 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2431 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
|
2432 } |
6705 | 2433 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2434 error ("graphics_handle::free: can't delete root figure"); |
6705 | 2435 } |
2436 } | |
6406 | 2437 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2438 void |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2439 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
|
2440 const graphics_handle& new_gh) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2441 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2442 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
|
2443 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2444 if (p != handle_map.end ()) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2445 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2446 graphics_object go = p->second; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2447 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2448 handle_map.erase (p); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2449 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2450 handle_map[new_gh] = go; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2451 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2452 if (old_gh.value () < 0) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2453 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
|
2454 - make_handle_fraction ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2455 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2456 else |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2457 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
|
2458 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2459 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
|
2460 q != figure_list.end (); q++) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2461 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2462 if (*q == old_gh) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2463 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2464 *q = new_gh; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2465 break; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2466 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2467 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2468 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2469 |
6406 | 2470 gh_manager *gh_manager::instance = 0; |
2471 | |
2472 static void | |
7189 | 2473 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 2474 const octave_value& val) |
2475 { | |
2476 graphics_object obj = gh_manager::get_object (h); | |
2477 obj.set (name, val); | |
2478 } | |
2479 | |
2480 static void | |
2481 xset (const graphics_handle& h, const octave_value_list& args) | |
2482 { | |
2483 if (args.length () > 0) | |
2484 { | |
2485 graphics_object obj = gh_manager::get_object (h); | |
2486 obj.set (args); | |
2487 } | |
2488 } | |
2489 | |
2490 static octave_value | |
7189 | 2491 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 2492 { |
2493 graphics_object obj = gh_manager::get_object (h); | |
2494 return obj.get (name); | |
2495 } | |
2496 | |
2497 static graphics_handle | |
2498 reparent (const octave_value& ov, const std::string& who, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2499 const std::string& property, const graphics_handle& new_parent, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2500 bool adopt = true) |
6406 | 2501 { |
2502 graphics_handle h = octave_NaN; | |
2503 | |
2504 double val = ov.double_value (); | |
2505 | |
2506 if (! error_state) | |
2507 { | |
2508 h = gh_manager::lookup (val); | |
2509 | |
7056 | 2510 if (h.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2511 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2512 graphics_object obj = gh_manager::get_object (h); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2513 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2514 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2515 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2516 graphics_object parent_obj = gh_manager::get_object (parent_h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2517 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2518 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2519 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2520 if (adopt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2521 obj.set ("parent", new_parent.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2522 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2523 obj.reparent (new_parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2524 } |
6406 | 2525 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2526 error ("%s: invalid graphics handle (= %g) for %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2527 who.c_str (), val, property.c_str ()); |
6406 | 2528 } |
2529 else | |
2530 error ("%s: expecting %s to be a graphics handle", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2531 who.c_str (), property.c_str ()); |
6406 | 2532 |
2533 return h; | |
2534 } | |
2535 | |
2536 // This function is NOT equivalent to the scripting language function gcf. | |
2537 graphics_handle | |
2538 gcf (void) | |
2539 { | |
2540 octave_value val = xget (0, "currentfigure"); | |
2541 | |
2542 return val.is_empty () ? octave_NaN : val.double_value (); | |
2543 } | |
2544 | |
2545 // This function is NOT equivalent to the scripting language function gca. | |
2546 graphics_handle | |
2547 gca (void) | |
2548 { | |
2549 octave_value val = xget (gcf (), "currentaxes"); | |
2550 | |
2551 return val.is_empty () ? octave_NaN : val.double_value (); | |
2552 } | |
2553 | |
2554 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
|
2555 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
|
2556 { |
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
|
2557 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
|
2558 { |
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
|
2559 graphics_object obj = gh_manager::get_object (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
|
2560 |
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
|
2561 // Don't do recursive deleting, due to callbacks |
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
|
2562 if (! obj.get_properties ().is_beingdeleted ()) |
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
|
2563 { |
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
|
2564 graphics_handle parent_h = obj.get_parent (); |
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
|
2565 |
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
|
2566 graphics_object parent_obj = |
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
|
2567 gh_manager::get_object (parent_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
|
2568 |
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
|
2569 // NOTE: free the handle before removing it from its |
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
|
2570 // parent's children, such that the object's |
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
|
2571 // state is correct when the deletefcn callback |
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
|
2572 // is executed |
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
|
2573 |
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
|
2574 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
|
2575 |
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
|
2576 // A callback function might have already deleted |
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
|
2577 // the parent |
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
|
2578 if (parent_obj.valid_object ()) |
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
|
2579 parent_obj.remove_child (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
|
2580 |
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
|
2581 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
|
2582 } |
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
|
2583 } |
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
|
2584 } |
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
|
2585 |
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
|
2586 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
|
2587 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
|
2588 { |
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
|
2589 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
|
2590 } |
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
|
2591 |
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
|
2592 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
|
2593 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
|
2594 { |
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
|
2595 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
|
2596 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
|
2597 } |
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
|
2598 |
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
|
2599 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
|
2600 close_figure (const graphics_handle& handle) |
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
|
2601 { |
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
|
2602 octave_value closerequestfcn = xget (handle, "closerequestfcn"); |
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
|
2603 |
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
|
2604 OCTAVE_SAFE_CALL (gh_manager::execute_callback, (handle, closerequestfcn)); |
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
|
2605 } |
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
|
2606 |
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
|
2607 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
|
2608 force_close_figure (const graphics_handle& handle) |
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
|
2609 { |
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
|
2610 // Remove the deletefcn and closerequestfcn callbacks and delete the |
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
|
2611 // object directly. |
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
|
2612 |
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
|
2613 xset (handle, "deletefcn", Matrix ()); |
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
|
2614 xset (handle, "closerequestfcn", Matrix ()); |
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
|
2615 |
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 (handle); |
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 |
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 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
|
2620 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
|
2621 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2622 // 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
|
2623 |
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
|
2624 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
|
2625 |
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
|
2626 // 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
|
2627 // 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
|
2628 |
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
|
2629 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
|
2630 |
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
|
2631 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
|
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 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
|
2634 |
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
|
2635 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
|
2636 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
|
2637 } |
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 // 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
|
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 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
|
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 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
|
2644 { |
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 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
|
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 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
|
2648 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
|
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 |
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 // 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
|
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 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
|
2654 |
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 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
|
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 // 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
|
2658 |
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
|
2659 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
|
2660 } |
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
|
2661 |
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
|
2662 static void |
6406 | 2663 adopt (const graphics_handle& p, const graphics_handle& h) |
2664 { | |
2665 graphics_object parent_obj = gh_manager::get_object (p); | |
2666 parent_obj.adopt (h); | |
2667 } | |
2668 | |
2669 static bool | |
7056 | 2670 is_handle (const graphics_handle& h) |
2671 { | |
2672 return h.ok (); | |
2673 } | |
2674 | |
2675 static bool | |
6406 | 2676 is_handle (double val) |
2677 { | |
6874 | 2678 graphics_handle h = gh_manager::lookup (val); |
2679 | |
2680 return h.ok (); | |
6406 | 2681 } |
2682 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2683 static octave_value |
6406 | 2684 is_handle (const octave_value& val) |
2685 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2686 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2687 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2688 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
|
2689 retval = true; |
12587
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2690 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
|
2691 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2692 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
|
2693 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2694 if (! error_state) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2695 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2696 boolNDArray result (handles.dims ()); |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2697 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2698 for (octave_idx_type i = 0; i < handles.numel (); i++) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2699 result.xelem (i) = is_handle (handles (i)); |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2700 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2701 retval = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2702 } |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2703 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2704 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2705 return retval; |
6406 | 2706 } |
2707 | |
2708 static bool | |
2709 is_figure (double val) | |
2710 { | |
2711 graphics_object obj = gh_manager::get_object (val); | |
2712 | |
2713 return obj && obj.isa ("figure"); | |
2714 } | |
2715 | |
7370 | 2716 static void |
2717 xcreatefcn (const graphics_handle& h) | |
2718 { | |
2719 graphics_object obj = gh_manager::get_object (h); | |
2720 obj.get_properties ().execute_createfcn (); | |
2721 } | |
2722 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2723 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2724 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
|
2725 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2726 graphics_object go = gh_manager::get_object (h); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
2727 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2728 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2729 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2730 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2731 |
6406 | 2732 // --------------------------------------------------------------------- |
2733 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2734 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2735 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
|
2736 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2737 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2738 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2739 update (go, id); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2740 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2741 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2742 bool |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2743 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
|
2744 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2745 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2746 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2747 return initialize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2748 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2749 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2750 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2751 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
|
2752 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2753 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2754 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2755 finalize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2756 } |
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
|
2757 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2758 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2759 |
6705 | 2760 void |
2761 base_properties::set_from_list (base_graphics_object& obj, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2762 property_list& defaults) |
6406 | 2763 { |
6705 | 2764 std::string go_name = graphics_object_name (); |
6406 | 2765 |
6705 | 2766 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 2767 |
6705 | 2768 if (p != defaults.end ()) |
2769 { | |
2770 const property_list::pval_map_type pval_map = p->second; | |
6406 | 2771 |
6705 | 2772 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
|
2773 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2774 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2775 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2776 std::string pname = q->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2777 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2778 obj.set (pname, q->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2779 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2780 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2781 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2782 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
|
2783 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2784 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2785 } |
6705 | 2786 } |
2787 } | |
6406 | 2788 |
7363 | 2789 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2790 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 2791 { |
2792 octave_value retval; | |
2793 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2794 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2795 all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2796 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2797 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2798 retval = it->second.get (); |
7363 | 2799 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2800 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 2801 |
2802 return retval; | |
2803 } | |
2804 | |
2805 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2806 base_properties::get_dynamic (bool all) const |
7363 | 2807 { |
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
|
2808 octave_scalar_map m; |
7363 | 2809 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2810 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
|
2811 it = all_props.begin (); it != all_props.end (); ++it) |
7379 | 2812 if (all || ! it->second.is_hidden ()) |
2813 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 2814 |
2815 return m; | |
2816 } | |
2817 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2818 std::set<std::string> |
9972 | 2819 base_properties::dynamic_property_names (void) const |
2820 { | |
2821 return dynamic_properties; | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2822 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2823 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2824 bool |
9972 | 2825 base_properties::has_dynamic_property (const std::string& pname) |
2826 { | |
2827 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
|
2828 |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2829 if (dynprops.find (pname) != dynprops.end ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2830 return true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2831 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2832 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
|
2833 } |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2834 |
7363 | 2835 void |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2836 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
|
2837 const octave_value& val) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2838 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2839 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
|
2840 all_props.find (pname); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2841 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2842 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2843 it->second.set (val); |
7363 | 2844 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2845 error ("set: unknown property \"%s\"", pname.c_str ()); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2846 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2847 if (! error_state) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2848 { |
9972 | 2849 dynamic_properties.insert (pname); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2850 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2851 mark_modified (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2852 } |
7363 | 2853 } |
2854 | |
2855 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2856 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 2857 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2858 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
2859 all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2860 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2861 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2862 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2863 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2864 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2865 } |
7363 | 2866 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2867 return it->second; |
7363 | 2868 } |
2869 | |
6705 | 2870 void |
6836 | 2871 base_properties::set_parent (const octave_value& val) |
6705 | 2872 { |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2873 double hnp = val.double_value (); |
6406 | 2874 |
6705 | 2875 graphics_handle new_parent = octave_NaN; |
6406 | 2876 |
6705 | 2877 if (! error_state) |
2878 { | |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2879 if (hnp == __myhandle__) |
17626
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2880 error ("set: can not set object parent to be object itself"); |
6705 | 2881 else |
17626
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2882 { |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2883 new_parent = gh_manager::lookup (hnp); |
17626
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2884 |
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2885 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
|
2886 { |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2887 // Remove child from current parent |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2888 graphics_object old_parent_obj; |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2889 old_parent_obj = gh_manager::get_object (get_parent ()); |
18517
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2890 |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2891 |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2892 if (old_parent_obj.get_handle () != hnp) |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2893 old_parent_obj.remove_child (__myhandle__); |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2894 else |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2895 // Do nothing more |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2896 return; |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2897 |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2898 // Check new parent's parent is not this child to avoid recursion |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2899 graphics_object new_parent_obj; |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2900 new_parent_obj = gh_manager::get_object (new_parent); |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2901 if (new_parent_obj.get_parent () == __myhandle__) |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2902 { |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2903 // new parent's parent gets child's original parent |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2904 new_parent_obj.get_properties ().set_parent (get_parent ().as_octave_value ()); |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2905 } |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2906 |
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2907 // 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
|
2908 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
|
2909 ::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
|
2910 } |
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2911 else |
17641
cd5a6008ae72
Fix recursion segfault when setting axis parent to be child hggroup (bug #37927).
Rik <rik@octave.org>
parents:
17631
diff
changeset
|
2912 error ("set: invalid graphics handle (= %g) for parent", hnp); |
17626
82b1778798d3
Fix segfault when setting object parent to be object itself (bug #37927).
Rik <rik@octave.org>
parents:
17608
diff
changeset
|
2913 } |
6705 | 2914 } |
2915 else | |
2916 error ("set: expecting parent to be a graphics handle"); | |
2917 } | |
6432 | 2918 |
18517
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2919 /* |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2920 %!test |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2921 %! 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
|
2922 %! unwind_protect |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2923 %! hax = gca (); |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2924 %! 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
|
2925 %! assert (gca (), hax) |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2926 %! unwind_protect_cleanup |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2927 %! close (hf); |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2928 %! end_unwind_protect |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2929 */ |
0cbd0d285541
Avoid reseting "parent" property to the same value (bug #37752).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18118
diff
changeset
|
2930 |
6705 | 2931 void |
6836 | 2932 base_properties::mark_modified (void) |
2933 { | |
7363 | 2934 __modified__ = "on"; |
2935 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 2936 if (parent_obj) |
2937 parent_obj.mark_modified (); | |
6836 | 2938 } |
2939 | |
2940 void | |
2941 base_properties::override_defaults (base_graphics_object& obj) | |
2942 { | |
7363 | 2943 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2944 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2945 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2946 parent_obj.override_defaults (obj); |
6836 | 2947 } |
2948 | |
2949 void | |
7214 | 2950 base_properties::update_axis_limits (const std::string& axis_type) const |
2951 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2952 graphics_object obj = gh_manager::get_object (__myhandle__); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2953 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2954 if (obj) |
7214 | 2955 obj.update_axis_limits (axis_type); |
2956 } | |
2957 | |
2958 void | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2959 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
|
2960 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
|
2961 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2962 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2963 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2964 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2965 obj.update_axis_limits (axis_type, h); |
6836 | 2966 } |
2967 | |
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
|
2968 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
|
2969 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
|
2970 { |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2971 return (handlevisibility.is ("on") |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
2972 || (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
|
2973 } |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2974 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2975 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2976 base_properties::get_toolkit (void) const |
7419 | 2977 { |
2978 graphics_object go = gh_manager::get_object (get_parent ()); | |
2979 | |
2980 if (go) | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2981 return go.get_toolkit (); |
7419 | 2982 else |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2983 return graphics_toolkit (); |
7419 | 2984 } |
2985 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2986 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2987 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
|
2988 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2989 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
|
2990 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2991 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
|
2992 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2993 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
|
2994 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2995 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2996 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
|
2997 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2998 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2999 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3000 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3001 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
|
3002 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3003 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3004 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3005 if (parent_obj.valid_object ()) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3006 parent_obj.get_properties ().update_autopos (elem_type); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3007 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3008 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3009 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3010 base_properties::add_listener (const caseless_str& nm, const octave_value& v, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3011 listener_mode mode) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3012 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3013 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3014 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3015 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3016 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3017 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
3018 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3019 void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3020 base_properties::delete_listener (const caseless_str& nm, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3021 const octave_value& v, listener_mode mode) |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3022 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3023 property p = get_property (nm); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3024 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3025 if (! error_state && p.ok ()) |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3026 p.delete_listener (v, mode); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3027 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3028 |
7363 | 3029 // --------------------------------------------------------------------- |
3030 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3031 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3032 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
|
3033 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3034 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
|
3035 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3036 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3037 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3038 if (parent_obj) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3039 parent_obj.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
|
3040 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3041 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3042 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
|
3043 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3044 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3045 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3046 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
|
3047 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
|
3048 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3049 if (valid_object ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3050 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3051 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3052 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3053 if (parent_obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3054 parent_obj.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
|
3055 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3056 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3057 error ("base_graphics_object::update_axis_limits: invalid graphics object"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3058 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3059 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3060 void |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3061 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
|
3062 { |
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
|
3063 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
|
3064 |
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
|
3065 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
|
3066 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
3067 // 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
|
3068 // 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
|
3069 // 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
|
3070 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
3071 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
3072 |
13849
b4b8e525dee0
Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents:
13830
diff
changeset
|
3073 frame.protect_var (error_state); |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
3074 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
|
3075 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
|
3076 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
|
3077 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
3078 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
|
3079 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
|
3080 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
|
3081 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
3082 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
|
3083 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
3084 if (! error_state && p.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3085 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
|
3086 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3087 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3088 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3089 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3090 base_graphics_object::values_as_string (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3091 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3092 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3093 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3094 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3095 { |
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
|
3096 octave_map m = get ().map_value (); |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3097 graphics_object obj = gh_manager::get_object (get_handle ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3098 |
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
|
3099 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
|
3100 { |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3101 if (pa->first != "children" && |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3102 ! obj.has_readonly_property (pa->first)) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3103 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3104 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3105 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3106 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3107 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3108 retval += "\n\t" + std::string (pa->first) + ": "; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3109 if (p.is_radio ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3110 retval += p.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3111 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3112 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3113 } |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3114 |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3115 if (! retval.empty ()) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3116 retval += "\n"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3117 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3118 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3119 error ("base_graphics_object::values_as_string: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3120 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3121 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3122 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3123 |
18117
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3124 std::string |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3125 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
|
3126 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3127 std::string retval; |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3128 |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3129 if (valid_object ()) |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3130 { |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3131 graphics_object obj = gh_manager::get_object (get_handle ()); |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3132 |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3133 if (prop != "children" && ! obj.has_readonly_property (prop)) |
18117
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3134 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3135 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
|
3136 |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3137 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
|
3138 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3139 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
|
3140 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
|
3141 } |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3142 } |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3143 |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
3144 if (! retval.empty ()) |
18117
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3145 retval += "\n"; |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3146 } |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3147 else |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3148 error ("base_graphics_object::value_as_string: invalid graphics object"); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3149 |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3150 return retval; |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3151 } |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
3152 |
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
|
3153 octave_scalar_map |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3154 base_graphics_object::values_as_struct (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3155 { |
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
|
3156 octave_scalar_map retval; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3157 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3158 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3159 { |
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
|
3160 octave_scalar_map m = get ().scalar_map_value (); |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3161 graphics_object obj = gh_manager::get_object (get_handle ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3162 |
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
|
3163 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
|
3164 pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3165 { |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3166 if (pa->first != "children" |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3167 && ! obj.has_readonly_property (pa->first)) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3168 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3169 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3170 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3171 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3172 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3173 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
|
3174 retval.assign (p.get_name (), p.values_as_cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3175 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
|
3176 retval.assign (p.get_name (), Cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3177 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3178 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3179 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3180 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3181 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3182 error ("base_graphics_object::values_as_struct: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3183 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3184 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3185 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
3186 |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3187 /* |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3188 %!test |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3189 %! 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:
18658
diff
changeset
|
3190 %! unwind_protect |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3191 %! hax = axes (); |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3192 %! 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:
18658
diff
changeset
|
3193 %! 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:
18658
diff
changeset
|
3194 %! 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:
18658
diff
changeset
|
3195 %! 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:
18658
diff
changeset
|
3196 %! ret = set (hfig, "__graphics_toolkit__"); |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3197 %! 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:
18658
diff
changeset
|
3198 %! 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:
18658
diff
changeset
|
3199 %! 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:
18658
diff
changeset
|
3200 %! 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:
18658
diff
changeset
|
3201 %! 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:
18658
diff
changeset
|
3202 %! 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:
18658
diff
changeset
|
3203 %! close (hfig); |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
3204 %! 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:
18658
diff
changeset
|
3205 */ |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3206 graphics_object |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
3207 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
|
3208 { |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3209 if (valid_object ()) |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3210 { |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
3211 if (isa (obj_type)) |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3212 return *this; |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3213 else |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
3214 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
|
3215 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3216 else |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3217 return graphics_object (); |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3218 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
3219 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3220 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3221 |
7363 | 3222 #include "graphics-props.cc" |
3223 | |
3224 // --------------------------------------------------------------------- | |
3225 | |
6836 | 3226 void |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3227 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
|
3228 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3229 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3230 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3231 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3232 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3233 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3234 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3235 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3236 if (! cbo_stack.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3237 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3238 val = cbo_stack.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3239 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3240 cbo_stack.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3241 } |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3242 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3243 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3244 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3245 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3246 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3247 if (get_callbackobject ().ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3248 cbo_stack.push_front (get_callbackobject ()); |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3249 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3250 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3251 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3252 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3253 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3254 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
3255 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3256 void |
18902
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3257 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:
18892
diff
changeset
|
3258 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3259 graphics_handle val (v); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3260 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3261 if (error_state) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3262 return; |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3263 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3264 if (xisnan (val.value ()) || is_handle (val)) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3265 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3266 currentfigure = val; |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3267 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3268 if (val.ok ()) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3269 gh_manager::push_figure (val); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3270 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3271 else |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3272 gripe_set_invalid ("currentfigure"); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3273 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3274 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3275 std::string |
18946
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3276 root_figure::properties::get_diary (void) const |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3277 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3278 bool is_diary_on = F__diarystate__ ()(0).bool_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3279 if (is_diary_on) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3280 return std::string ("on"); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3281 else |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3282 return std::string ("off"); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3283 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3284 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3285 void |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3286 root_figure::properties::set_diary (const octave_value& val) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3287 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3288 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3289 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3290 // Input checking and abrev. matching |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3291 diary.set (val, false); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3292 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3293 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3294 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3295 Fdiary (ovl (diary.current_value ())); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3296 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3297 diary.run_listeners (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3298 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3299 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3300 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3301 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3302 std::string |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3303 root_figure::properties::get_diaryfile (void) const |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3304 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3305 return F__diaryfile__ ()(0).string_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3306 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3307 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3308 void |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3309 root_figure::properties::set_diaryfile (const octave_value& val) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3310 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3311 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3312 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3313 // Input checking and abrev. matching |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3314 diaryfile.set (val, false); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3315 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3316 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3317 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3318 Fdiary (ovl (diaryfile.string_value ())); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3319 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3320 diaryfile.run_listeners (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3321 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3322 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3323 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3324 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3325 std::string |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3326 root_figure::properties::get_echo (void) const |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3327 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3328 bool is_echo_on = F__echostate__ ()(0).bool_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3329 if (is_echo_on) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3330 return std::string ("on"); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3331 else |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3332 return std::string ("off"); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3333 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3334 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3335 void |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3336 root_figure::properties::set_echo (const octave_value& val) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3337 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3338 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3339 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3340 // Input checking and abrev. matching |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3341 echo.set (val, false); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3342 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3343 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3344 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3345 Fecho (ovl (echo.current_value ())); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3346 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3347 echo.run_listeners (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3348 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3349 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3350 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3351 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3352 std::string |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3353 root_figure::properties::get_errormessage (void) const |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3354 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3355 return Flasterr ()(0).string_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3356 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3357 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3358 std::string |
18902
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3359 root_figure::properties::get_format (void) const |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3360 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3361 return F__formatstring__ ()(0).string_value (); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3362 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3363 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3364 void |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3365 root_figure::properties::set_format (const octave_value& val) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3366 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3367 if (! error_state) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3368 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3369 // Input checking and abrev. matching |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3370 format.set (val, false); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3371 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3372 if (! error_state) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3373 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3374 Fformat (ovl (format.current_value ())); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3375 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3376 format.run_listeners (); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3377 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3378 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3379 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3380 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3381 std::string |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3382 root_figure::properties::get_formatspacing (void) const |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3383 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3384 bool iscompact = F__compactformat__ ()(0).bool_value (); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3385 if (iscompact) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3386 return std::string ("compact"); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3387 else |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3388 return std::string ("loose"); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3389 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3390 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3391 void |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3392 root_figure::properties::set_formatspacing (const octave_value& val) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3393 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3394 if (! error_state) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3395 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3396 // Input checking and abrev. matching |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3397 formatspacing.set (val, false); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3398 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3399 if (! error_state) |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3400 { |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3401 std::string strval = formatspacing.current_value (); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3402 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3403 if (strval == "compact") |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3404 F__compactformat__ (ovl (true)); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3405 else |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3406 F__compactformat__ (ovl (false)); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3407 |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3408 formatspacing.run_listeners (); |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3409 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3410 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3411 } |
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3412 |
18946
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3413 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3414 double |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3415 root_figure::properties::get_recursionlimit (void) const |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3416 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3417 return Fmax_recursion_depth ()(0).double_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3418 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3419 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3420 void |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3421 root_figure::properties::set_recursionlimit (const octave_value& val) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3422 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3423 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3424 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3425 // Input checking and abrev. matching |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3426 recursionlimit.set (val, false); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3427 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3428 if (! error_state) |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3429 { |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3430 double dval = recursionlimit.double_value (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3431 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3432 Fmax_recursion_depth (ovl (dval)); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3433 |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3434 recursionlimit.run_listeners (); |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3435 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3436 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3437 } |
89448a7523b2
Add some more callbacks for root properties (bug #42347).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18902
diff
changeset
|
3438 |
18902
9fbb254c09e6
build: Fix compiling with new graphic root properties (cset 28eab2d84190).
Rik <rik@octave.org>
parents:
18892
diff
changeset
|
3439 void |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3440 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
|
3441 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3442 if (! error_state) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3443 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3444 if (integerhandle.set (val, true)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3445 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3446 bool int_fig_handle = integerhandle.is_on (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3447 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3448 graphics_object this_go = gh_manager::get_object (__myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3449 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3450 graphics_handle old_myhandle = __myhandle__; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3451 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3452 __myhandle__ = gh_manager::get_handle (int_fig_handle); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3453 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3454 gh_manager::renumber_figure (old_myhandle, __myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3455 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3456 graphics_object parent_go = gh_manager::get_object (get_parent ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3457 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3458 base_properties& props = parent_go.get_properties (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3459 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3460 props.renumber_child (old_myhandle, __myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3461 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3462 Matrix kids = get_children (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3463 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3464 for (octave_idx_type i = 0; i < kids.numel (); i++) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3465 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3466 graphics_object kid = gh_manager::get_object (kids(i)); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3467 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3468 kid.get_properties ().renumber_parent (__myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3469 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3470 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3471 graphics_handle cf = gh_manager::current_figure (); |
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 if (__myhandle__ == cf) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3474 xset (0, "currentfigure", __myhandle__.value ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3475 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3476 this_go.update (integerhandle.get_id ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3477 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3478 mark_modified (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3479 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3480 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3481 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3482 |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17842
diff
changeset
|
3483 // FIXME: This should update monitorpositions and pointerlocation, but |
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
|
3484 // as these properties are yet used, and so it doesn't matter that they |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3485 // aren't set yet. |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3486 void |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3487 root_figure::properties::update_units (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3488 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3489 caseless_str xunits = get_units (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3490 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3491 Matrix ss = default_screensize (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3492 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3493 double dpi = get_screenpixelsperinch (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3494 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3495 if (xunits.compare ("inches")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3496 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3497 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3498 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3499 ss(2) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3500 ss(3) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3501 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3502 else if (xunits.compare ("centimeters")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3503 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3504 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3505 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3506 ss(2) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3507 ss(3) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3508 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3509 else if (xunits.compare ("normalized")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3510 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3511 ss = Matrix (1, 4, 1.0); |
14266
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3512 ss(0) = 0; |
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3513 ss(1) = 0; |
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 else if (xunits.compare ("points")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3516 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3517 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3518 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3519 ss(2) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3520 ss(3) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3521 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3522 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3523 set_screensize (ss); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3524 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3525 |
14357
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3526 Matrix |
14604
de72463862c4
Silence warnings
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
14498
diff
changeset
|
3527 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
|
3528 { |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3529 Matrix screen_size = screen_size_pixels (); |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3530 Matrix pos = Matrix (1, 4, 0); |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3531 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
|
3532 pos(3) = screen_size(1); |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3533 return pos; |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3534 } |
e7c74f56cd03
fltk toolkit requires figure units to be "pixels". Bug # 35430.
Ben Abbott <bpabbott@mac.com>
parents:
14326
diff
changeset
|
3535 |
14266
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3536 /* |
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3537 %!test |
17237
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3538 %! old_units = get (0, "units"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3539 %! unwind_protect |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3540 %! set (0, "units", "pixels"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3541 %! 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
|
3542 %! dpi = get (0, "screenpixelsperinch"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3543 %! set (0, "units", "inches"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3544 %! 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
|
3545 %! set (0, "units", "centimeters"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3546 %! 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
|
3547 %! set (0, "units", "points"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3548 %! 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
|
3549 %! set (0, "units", "normalized"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3550 %! 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
|
3551 %! set (0, "units", "pixels"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3552 %! 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
|
3553 %! unwind_protect_cleanup |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3554 %! set (0, "units", old_units); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
3555 %! end_unwind_protect |
14266
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3556 */ |
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
3557 |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3558 void |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3559 root_figure::properties::remove_child (const graphics_handle& gh) |
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 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3562 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3563 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3564 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3565 xset (0, "currentfigure", cf.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3566 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3567 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3568 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3569 |
6406 | 3570 property_list |
3571 root_figure::factory_properties = root_figure::init_factory_properties (); | |
3572 | |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3573 static void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3574 reset_default_properties (property_list& default_properties) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3575 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3576 property_list new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3577 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3578 for (property_list::plist_map_const_iterator p = default_properties.begin (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3579 p != default_properties.end (); p++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3580 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3581 const property_list::pval_map_type pval_map = p->second; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3582 std::string prefix = p->first; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3583 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3584 for (property_list::pval_map_const_iterator q = pval_map.begin (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3585 q != pval_map.end (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3586 q++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3587 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3588 std::string s = q->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3589 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3590 if (prefix == "axes" && (s == "position" || s == "units")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3591 new_defaults.set (prefix + s, q->second); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3592 else if (prefix == "figure" && (s == "position" || s == "units" |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3593 || s == "windowstyle" |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3594 || s == "paperunits")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3595 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3596 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3597 } |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3598 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3599 default_properties = new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3600 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3601 |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3602 void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3603 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
|
3604 { |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3605 ::reset_default_properties (default_properties); |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3606 } |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3607 |
6406 | 3608 // --------------------------------------------------------------------- |
3609 | |
7363 | 3610 void |
3611 figure::properties::set_currentaxes (const octave_value& v) | |
3612 { | |
7378 | 3613 graphics_handle val (v); |
6705 | 3614 |
6874 | 3615 if (error_state) |
3616 return; | |
3617 | |
7070 | 3618 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 3619 currentaxes = val; |
3620 else | |
3621 gripe_set_invalid ("currentaxes"); | |
3622 } | |
3623 | |
3624 void | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3625 figure::properties::remove_child (const graphics_handle& gh) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3626 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3627 base_properties::remove_child (gh); |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3628 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3629 if (gh == currentaxes.handle_value ()) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3630 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3631 graphics_handle new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3632 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3633 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
|
3634 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3635 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
|
3636 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3637 graphics_handle kid = kids(i); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3638 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3639 graphics_object go = gh_manager::get_object (kid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3640 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3641 if (go.isa ("axes")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3642 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3643 new_currentaxes = kid; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3644 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3645 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3646 } |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3647 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3648 currentaxes = new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3649 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3650 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3651 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3652 void |
6874 | 3653 figure::properties::set_visible (const octave_value& val) |
3654 { | |
3655 std::string s = val.string_value (); | |
3656 | |
3657 if (! error_state) | |
3658 { | |
3659 if (s == "on") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3660 xset (0, "currentfigure", __myhandle__.value ()); |
6874 | 3661 |
3662 visible = val; | |
3663 } | |
3664 } | |
3665 | |
7445 | 3666 Matrix |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3667 figure::properties::get_boundingbox (bool internal, const Matrix&) const |
7445 | 3668 { |
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
|
3669 Matrix screen_size = screen_size_pixels (); |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3670 Matrix pos = (internal ? |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3671 get_position ().matrix_value () : |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3672 get_outerposition ().matrix_value ()); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3673 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3674 pos = convert_position (pos, get_units (), "pixels", screen_size); |
7445 | 3675 |
3676 pos(0)--; | |
3677 pos(1)--; | |
7447 | 3678 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 3679 |
3680 return pos; | |
3681 } | |
3682 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3683 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3684 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
|
3685 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
|
3686 { |
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
|
3687 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
|
3688 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
|
3689 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3690 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
|
3691 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
|
3692 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
|
3693 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
|
3694 |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3695 if (internal) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3696 set_position (pos, do_notify_toolkit); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3697 else |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3698 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
|
3699 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3700 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3701 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3702 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
|
3703 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3704 Matrix bb = get_boundingbox (true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3705 Matrix pos (1, 2, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3706 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3707 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
|
3708 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
|
3709 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3710 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
|
3711 pos(0)++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3712 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
|
3713 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
|
3714 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3715 return pos; |
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 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3718 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3719 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
|
3720 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3721 Matrix bb = get_boundingbox (true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3722 Matrix pos (1, 2, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3723 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3724 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
|
3725 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
|
3726 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3727 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
|
3728 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
|
3729 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3730 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
|
3731 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3732 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3733 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3734 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3735 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3736 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
|
3737 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
|
3738 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3739 if (! error_state) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3740 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3741 Matrix old_bb, new_bb; |
14367
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3742 bool modified = false; |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3743 |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3744 old_bb = get_boundingbox (true); |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3745 modified = position.set (v, false, do_notify_toolkit); |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3746 new_bb = get_boundingbox (true); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3747 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3748 if (old_bb != new_bb) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3749 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3750 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3751 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3752 execute_resizefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3753 update_boundingbox (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3754 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3755 } |
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 |
14367
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3757 if (modified) |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3758 { |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3759 position.run_listeners (POSTSET); |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3760 mark_modified (); |
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
3761 } |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3762 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3763 if (paperpositionmode.is ("auto")) |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3764 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
|
3765 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3766 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3767 |
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 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3769 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
|
3770 bool do_notify_toolkit) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3771 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3772 if (! error_state) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3773 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3774 if (outerposition.set (v, true, do_notify_toolkit)) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3775 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3776 mark_modified (); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3777 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3778 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3779 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3780 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3781 void |
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
|
3782 figure::properties::set_paperunits (const octave_value& v) |
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 if (! error_state) |
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 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3786 caseless_str typ = get_papertype (); |
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 caseless_str punits = v.string_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
|
3788 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3789 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3790 if (punits.compare ("normalized") && typ.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
|
3791 error ("set: can't set the paperunits to normalized when the papertype is custom"); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3792 else |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3793 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3794 caseless_str old_paperunits = get_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
|
3795 if (paperunits.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3796 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3797 update_paperunits (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
|
3798 mark_modified (); |
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 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3804 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3805 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
|
3806 figure::properties::set_papertype (const octave_value& v) |
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 (! error_state) |
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 caseless_str typ = v.string_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
|
3811 caseless_str punits = get_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
|
3812 if (! error_state) |
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 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3814 if (punits.compare ("normalized") && typ.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
|
3815 error ("set: can't set the paperunits to normalized when the papertype is custom"); |
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 else |
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 if (papertype.set (v, true)) |
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 update_papertype (); |
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 mark_modified (); |
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 } |
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 } |
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 } |
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 static Matrix |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3829 papersize_from_type (const caseless_str punits, const caseless_str typ) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3830 { |
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
|
3831 Matrix ret (1, 2, 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
|
3832 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3833 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
|
3834 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3835 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
|
3836 double mm2units; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3837 |
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
|
3838 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
|
3839 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3840 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
|
3841 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
|
3842 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3843 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
|
3844 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3845 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
|
3846 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
|
3847 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3848 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
|
3849 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3850 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
|
3851 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
|
3852 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3853 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3854 if (typ.compare ("usletter")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3855 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3856 ret (0) = 8.5 * 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
|
3857 ret (1) = 11.0 * 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
|
3858 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3859 else if (typ.compare ("uslegal")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3860 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3861 ret (0) = 8.5 * 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
|
3862 ret (1) = 14.0 * 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
|
3863 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3864 else if (typ.compare ("tabloid")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3865 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3866 ret (0) = 11.0 * 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
|
3867 ret (1) = 17.0 * 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
|
3868 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3869 else if (typ.compare ("a0")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3870 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3871 ret (0) = 841.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3872 ret (1) = 1189.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3873 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3874 else if (typ.compare ("a1")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3875 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3876 ret (0) = 594.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3877 ret (1) = 841.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3878 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3879 else if (typ.compare ("a2")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3880 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3881 ret (0) = 420.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3882 ret (1) = 594.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3883 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3884 else if (typ.compare ("a3")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3885 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3886 ret (0) = 297.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3887 ret (1) = 420.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3888 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3889 else if (typ.compare ("a4")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3890 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3891 ret (0) = 210.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3892 ret (1) = 297.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3893 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3894 else if (typ.compare ("a5")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3895 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3896 ret (0) = 148.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3897 ret (1) = 210.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3898 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3899 else if (typ.compare ("b0")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3900 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3901 ret (0) = 1029.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3902 ret (1) = 1456.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3903 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3904 else if (typ.compare ("b1")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3905 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3906 ret (0) = 728.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3907 ret (1) = 1028.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3908 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3909 else if (typ.compare ("b2")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3910 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3911 ret (0) = 514.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3912 ret (1) = 728.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3913 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3914 else if (typ.compare ("b3")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3915 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3916 ret (0) = 364.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3917 ret (1) = 514.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3918 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3919 else if (typ.compare ("b4")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3920 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3921 ret (0) = 257.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3922 ret (1) = 364.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3923 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3924 else if (typ.compare ("b5")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3925 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3926 ret (0) = 182.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3927 ret (1) = 257.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3928 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3929 else if (typ.compare ("arch-a")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3930 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3931 ret (0) = 9.0 * 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
|
3932 ret (1) = 12.0 * 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
|
3933 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3934 else if (typ.compare ("arch-b")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3935 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3936 ret (0) = 12.0 * 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
|
3937 ret (1) = 18.0 * 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
|
3938 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3939 else if (typ.compare ("arch-c")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3940 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3941 ret (0) = 18.0 * 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
|
3942 ret (1) = 24.0 * 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
|
3943 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3944 else if (typ.compare ("arch-d")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3945 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3946 ret (0) = 24.0 * 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
|
3947 ret (1) = 36.0 * 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
|
3948 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3949 else if (typ.compare ("arch-e")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3950 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3951 ret (0) = 36.0 * 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
|
3952 ret (1) = 48.0 * 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
|
3953 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3954 else if (typ.compare ("a")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3955 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3956 ret (0) = 8.5 * 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
|
3957 ret (1) = 11.0 * 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
|
3958 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3959 else if (typ.compare ("b")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3960 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3961 ret (0) = 11.0 * 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
|
3962 ret (1) = 17.0 * 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
|
3963 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3964 else if (typ.compare ("c")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3965 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3966 ret (0) = 17.0 * 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
|
3967 ret (1) = 22.0 * 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
|
3968 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3969 else if (typ.compare ("d")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3970 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3971 ret (0) = 22.0 * 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
|
3972 ret (1) = 34.0 * 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
|
3973 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3974 else if (typ.compare ("e")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3975 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3976 ret (0) = 34.0 * 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
|
3977 ret (1) = 43.0 * 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
|
3978 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3979 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3980 |
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
|
3981 return ret; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3982 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3983 |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3984 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3985 Matrix |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3986 figure::properties::get_auto_paperposition (void) |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3987 { |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3988 Matrix pos = get_position ().matrix_value (); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3989 Matrix sz; |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3990 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3991 caseless_str funits = get_units (); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3992 caseless_str punits = get_paperunits (); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3993 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3994 // Convert position from figure units to paperunits |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3995 if (funits == "normalized" || punits == "normalized") |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3996 { |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3997 sz = screen_size_pixels (); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3998 pos = convert_position (pos, funits, "inches", sz); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
3999 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4000 if (punits == "normalized") |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4001 sz = papersize_from_type ("points", get_papertype ()); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4002 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4003 pos = convert_position (pos, "inches", punits, sz); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4004 } |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4005 else |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4006 pos = convert_position (pos, funits, punits, sz); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4007 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4008 // Center the figure on the page |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4009 sz = get_papersize ().matrix_value (); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4010 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4011 pos(0) = sz(0)/2 - pos(2)/2; |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4012 pos(1) = sz(1)/2 - pos(3)/2; |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4013 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4014 return pos; |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4015 } |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4016 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4017 /* |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4018 %!test |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4019 %! hf = figure ("visible", "off", "paperpositionmode", "auto"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4020 %! in_pos = [0 0 4 5]; |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4021 %! tol = 20 * eps (); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4022 %! unwind_protect |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4023 %! ## paperpositionmode "auto" converts figure size to paper units |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4024 %! set (hf, "units", "inches"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4025 %! set (hf, "position", in_pos); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4026 %! set (hf, "paperunits", "centimeters"); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4027 %! psz = get (hf, "papersize"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4028 %! fsz = in_pos(3:4) * 2.54; |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4029 %! pos = [(psz/2 .- fsz/2) fsz]; |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4030 %! set (hf, "paperpositionmode", "auto"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4031 %! assert (get (hf, "paperposition"), pos, tol) |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4032 %! unwind_protect_cleanup |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4033 %! close (hf); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4034 %! end_unwind_protect |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4035 |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4036 %!test |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4037 %! hf = figure ("visible", "off", "paperpositionmode", "auto"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4038 %! in_pos = [0 0 4 5]; |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4039 %! tol = 20 * eps (); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4040 %! unwind_protect |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4041 %! ## likewise with normalized units |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4042 %! set (hf, "units", "inches"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4043 %! set (hf, "position", in_pos); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4044 %! psz = get (hf, "papersize"); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4045 %! set (hf, "paperunits", "normalized"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4046 %! fsz = in_pos(3:4) ./ psz; |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4047 %! pos = [([0.5 0.5] .- fsz/2) fsz]; |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4048 %! assert (get (hf, "paperposition"), pos, tol) |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4049 %! unwind_protect_cleanup |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4050 %! close (hf); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4051 %! end_unwind_protect |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4052 |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4053 %!test |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4054 %! hf = figure ("visible", "off", "paperpositionmode", "auto"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4055 %! in_pos = [0 0 4 5]; |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4056 %! tol = 20 * eps (); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4057 %! unwind_protect |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4058 %! ## changing papertype updates paperposition |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4059 %! set (hf, "units", "inches"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4060 %! set (hf, "position", in_pos); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4061 %! set (hf, "papertype", "a4"); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4062 %! psz = get (hf, "papersize"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4063 %! fsz = in_pos(3:4); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4064 %! pos = [(psz/2 .- fsz/2) fsz]; |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4065 %! assert (get (hf, "paperposition"), pos, tol) |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4066 %! unwind_protect_cleanup |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4067 %! close (hf); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4068 %! end_unwind_protect |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4069 |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4070 %!test |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4071 %! hf = figure ("visible", "off", "paperpositionmode", "auto"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4072 %! in_pos = [0 0 4 5]; |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4073 %! tol = 20 * eps (); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4074 %! unwind_protect |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4075 %! ## lanscape updates paperposition |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4076 %! set (hf, "units", "inches"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4077 %! set (hf, "position", in_pos); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4078 %! set (hf, "paperorientation", "landscape"); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4079 %! psz = get (hf, "papersize"); |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4080 %! fsz = in_pos(3:4); |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4081 %! pos = [(psz/2 .- fsz/2) fsz]; |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4082 %! assert (get (hf, "paperposition"), pos, tol) |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4083 %! unwind_protect_cleanup |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4084 %! close (hf); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4085 %! end_unwind_protect |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4086 |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4087 %!test |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4088 %! hf = figure ("visible", "off", "paperpositionmode", "auto"); |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4089 %! in_pos = [0 0 4 5]; |
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4090 %! unwind_protect |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4091 %! ## back to manual mode |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4092 %! set (hf, "paperposition", in_pos * 1.1) |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4093 %! assert (get (hf, "paperpositionmode"), "manual") |
19082
2420a4f22998
Fix tolerance issues in %!test from cset70ea5a2856fe (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19081
diff
changeset
|
4094 %! assert (get (hf, "paperposition"), in_pos * 1.1) |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4095 %! unwind_protect_cleanup |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4096 %! close (hf); |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4097 %! end_unwind_protect |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4098 */ |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4099 |
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
|
4100 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
|
4101 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
|
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 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
|
4104 Matrix sz = get_papersize ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4105 |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4106 pos(0) /= sz(0); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4107 pos(1) /= sz(1); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4108 pos(2) /= sz(0); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4109 pos(3) /= sz(1); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4110 |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4111 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
|
4112 caseless_str punits = get_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
|
4113 caseless_str typ = get_papertype (); |
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 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
4115 if (typ.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
|
4116 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4117 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
|
4118 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4119 sz(0) /= 2.54; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4120 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
|
4121 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4122 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
|
4123 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4124 sz(0) /= 72.0; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4125 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
|
4126 } |
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 |
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 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
|
4129 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4130 sz(0) *= 2.54; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4131 sz(1) *= 2.54; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4132 } |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4133 else if (punits.compare ("points")) |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4134 { |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4135 sz(0) *= 72.0; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4136 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
|
4137 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4138 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4139 else |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4140 { |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4141 sz = papersize_from_type (punits, typ); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4142 if (porient == "landscape") |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4143 std::swap (sz(0), sz(1)); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4144 } |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4145 |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4146 pos(0) *= sz(0); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4147 pos(1) *= sz(1); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4148 pos(2) *= sz(0); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4149 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
|
4150 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4151 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
|
4152 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
|
4153 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4154 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4155 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
|
4156 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
|
4157 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4158 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
|
4159 if (! typ.compare ("<custom>")) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4160 { |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4161 Matrix sz = papersize_from_type (get_paperunits (), typ); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4162 if (get_paperorientation () == "landscape") |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4163 std::swap (sz(0), sz(1)); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4164 // Call papersize.set rather than set_papersize to avoid loops |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4165 // 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
|
4166 papersize.set (octave_value (sz)); |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4167 } |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4168 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4169 if (paperpositionmode.is ("auto")) |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4170 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
|
4171 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4172 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4173 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
|
4174 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
|
4175 { |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4176 Matrix sz = get_papersize ().matrix_value (); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4177 if (sz(0) > sz(1)) |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4178 { |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4179 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
|
4180 papersize.set (octave_value (sz)); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4181 paperorientation.set (octave_value ("landscape")); |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4182 } |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4183 else |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4184 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4185 paperorientation.set ("portrait"); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4186 } |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4187 std::string punits = get_paperunits (); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4188 if (punits == "centimeters") |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4189 { |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4190 sz(0) /= 2.54; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4191 sz(1) /= 2.54; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4192 } |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4193 else if (punits == "points") |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4194 { |
14498
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4195 sz(0) /= 72.0; |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4196 sz(1) /= 72.0; |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4197 } |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4198 if (punits == "normalized") |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4199 { |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4200 caseless_str typ = get_papertype (); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4201 if (get_papertype () == "<custom>") |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4202 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
|
4203 } |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4204 else |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4205 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4206 // TODO - the papersizes info is also in papersize_from_type(). |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4207 // Both should be rewritten to avoid the duplication. |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4208 std::string typ = "<custom>"; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4209 const double mm2in = 1.0 / 25.4; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4210 const double tol = 0.01; |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4211 |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4212 if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 11.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4213 typ = "usletter"; |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4214 else if (std::abs (sz(0) - 8.5) + std::abs (sz(1) - 14.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4215 typ = "uslegal"; |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4216 else if (std::abs (sz(0) - 11.0) + std::abs (sz(1) - 17.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4217 typ = "tabloid"; |
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) - 841.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) - 1198.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4220 typ = "a0"; |
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) - 594.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) - 841.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4223 typ = "a1"; |
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) - 420.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) - 594.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4226 typ = "a2"; |
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) - 297.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) - 420.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4229 typ = "a3"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4230 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
|
4231 + std::abs (sz(1) - 297.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4232 typ = "a4"; |
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) - 148.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4234 + std::abs (sz(1) - 210.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4235 typ = "a5"; |
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) - 1029.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4237 + std::abs (sz(1) - 1456.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4238 typ = "b0"; |
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) - 728.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4240 + std::abs (sz(1) - 1028.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4241 typ = "b1"; |
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) - 514.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4243 + std::abs (sz(1) - 728.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4244 typ = "b2"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4245 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
|
4246 + std::abs (sz(1) - 514.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4247 typ = "b3"; |
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) - 257.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4249 + std::abs (sz(1) - 364.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4250 typ = "b4"; |
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) - 182.0 * mm2in) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4252 + std::abs (sz(1) - 257.0 * mm2in) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4253 typ = "b5"; |
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) - 9.0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4255 + std::abs (sz(1) - 12.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4256 typ = "arch-a"; |
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) - 12.0) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4258 + std::abs (sz(1) - 18.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4259 typ = "arch-b"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4260 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
|
4261 + std::abs (sz(1) - 24.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4262 typ = "arch-c"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4263 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
|
4264 + std::abs (sz(1) - 36.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4265 typ = "arch-d"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4266 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
|
4267 + std::abs (sz(1) - 48.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4268 typ = "arch-e"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4269 else if (std::abs (sz(0) - 8.5) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4270 + std::abs (sz(1) - 11.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4271 typ = "a"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4272 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
|
4273 + std::abs (sz(1) - 17.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4274 typ = "b"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4275 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
|
4276 + std::abs (sz(1) - 22.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4277 typ = "c"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4278 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
|
4279 + std::abs (sz(1) - 34.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4280 typ = "d"; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
4281 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
|
4282 + std::abs (sz(1) - 43.0) < tol) |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4283 typ = "e"; |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4284 // 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
|
4285 // update_papersize and update_papertype |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4286 papertype.set (typ); |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4287 } |
14498
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4288 if (punits == "centimeters") |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4289 { |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4290 sz(0) *= 2.54; |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4291 sz(1) *= 2.54; |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4292 } |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4293 else if (punits == "points") |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4294 { |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4295 sz(0) *= 72.0; |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4296 sz(1) *= 72.0; |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4297 } |
14457
008a29999c3d
Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents:
14429
diff
changeset
|
4298 if (get_paperorientation () == "landscape") |
008a29999c3d
Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents:
14429
diff
changeset
|
4299 { |
008a29999c3d
Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents:
14429
diff
changeset
|
4300 std::swap (sz(0), sz(1)); |
008a29999c3d
Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents:
14429
diff
changeset
|
4301 papersize.set (octave_value (sz)); |
008a29999c3d
Save the papersize property in the proper orientation.
Ben Abbott <bpabbott@mac.com>
parents:
14429
diff
changeset
|
4302 } |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4303 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4304 if (paperpositionmode.is ("auto")) |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4305 paperposition.set (get_auto_paperposition ()); |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4306 } |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4307 |
14498
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4308 /* |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4309 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4310 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4311 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4312 %! set (hf, "paperunits", "inches"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4313 %! 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
|
4314 %! set (hf, "paperunits", "points"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4315 %! 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
|
4316 %! papersize = get (hf, "papersize"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4317 %! 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
|
4318 %! set (hf, "papersize", papersize); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4319 %! 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
|
4320 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4321 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4322 %! end_unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4323 |
14498
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4324 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4325 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4326 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4327 %! set (hf, "paperunits", "inches"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4328 %! 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
|
4329 %! set (hf, "paperunits", "centimeters"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4330 %! 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
|
4331 %! papersize = get (hf, "papersize"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4332 %! 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
|
4333 %! set (hf, "papersize", papersize); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4334 %! 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
|
4335 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4336 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4337 %! end_unwind_protect |
14498
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4338 */ |
36cfbd23fe9f
Fix papersize updater. Bug # 35908.
Ben Abbott <bpabbott@mac.com>
parents:
14483
diff
changeset
|
4339 |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4340 void |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4341 figure::properties::update_paperorientation (void) |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4342 { |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4343 std::string porient = get_paperorientation (); |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4344 Matrix sz = get_papersize ().matrix_value (); |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4345 Matrix pos = get_paperposition ().matrix_value (); |
14258
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4346 if ((sz(0) > sz(1) && porient == "portrait") |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4347 || (sz(0) < sz(1) && porient == "landscape")) |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4348 { |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4349 std::swap (sz(0), sz(1)); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4350 std::swap (pos(0), pos(1)); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4351 std::swap (pos(2), pos(3)); |
08779abcb640
maint: Style fixes for 5cc69bafe3b9
Rik <octave@nomad.inbox5.com>
parents:
14257
diff
changeset
|
4352 // 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
|
4353 // 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
|
4354 papersize.set (octave_value (sz)); |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4355 paperposition.set (octave_value (pos)); |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4356 } |
18962
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4357 |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4358 if (paperpositionmode.is ("auto")) |
70ea5a2856fe
Handle figure paperpositionmode "auto" (bug #37554)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18946
diff
changeset
|
4359 paperposition.set (get_auto_paperposition ()); |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4360 } |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4361 |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4362 /* |
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4363 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4364 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4365 %! unwind_protect |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4366 %! tol = 100 * eps (); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4367 %! ## 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
|
4368 %! set (hf, "paperorientation", "PORTRAIT"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4369 %! set (hf, "paperunits", "inches"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4370 %! set (hf, "papertype", "USletter"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4371 %! 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
|
4372 %! set (hf, "paperorientation", "Landscape"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4373 %! 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
|
4374 %! set (hf, "paperunits", "centimeters"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4375 %! 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
|
4376 %! set (hf, "papertype", "a4"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4377 %! 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
|
4378 %! 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
|
4379 %! 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
|
4380 %! 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
|
4381 %! 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
|
4382 %! 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
|
4383 %! 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
|
4384 %! unwind_protect_cleanup |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4385 %! close (hf); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4386 %! end_unwind_protect |
14257
5cc69bafe3b9
Add updating for figure paperorientation property. Bug # 35329.
Ben Abbott <bpabbott@mac.com>
parents:
14138
diff
changeset
|
4387 */ |
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
|
4388 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4389 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
|
4390 figure::properties::set_units (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4391 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4392 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4393 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4394 caseless_str old_units = get_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
|
4395 if (units.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4396 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4397 update_units (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
|
4398 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4399 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4400 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4401 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4402 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4403 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
|
4404 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
|
4405 { |
14367
ba01a38bc5c1
Use internal bounding box in figure::properties::set_position.
Ben Abbott <bpabbott@mac.com>
parents:
14357
diff
changeset
|
4406 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
|
4407 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
|
4408 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4409 |
14266
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
4410 /* |
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
4411 %!test |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4412 %! hf = figure ("visible", "off"); |
17237
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4413 %! old_units = get (0, "units"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4414 %! unwind_protect |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4415 %! set (0, "units", "pixels"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4416 %! rsz = get (0, "screensize"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4417 %! set (gcf (), "units", "pixels"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4418 %! fsz = get (gcf (), "position"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4419 %! set (gcf (), "units", "normalized"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4420 %! pos = get (gcf (), "position"); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4421 %! 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
|
4422 %! unwind_protect_cleanup |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4423 %! close (hf); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4424 %! set (0, "units", old_units); |
5f14fc8feba3
graphics.cc: Restore default graphics properties after %!tests.
Rik <rik@octave.org>
parents:
17223
diff
changeset
|
4425 %! end_unwind_protect |
14266
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
4426 */ |
37ca58f9a887
When root_figure units = normalized, screensize = [0 0 1 1].
Ben Abbott <bpabbott@mac.com>
parents:
14258
diff
changeset
|
4427 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4428 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4429 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4430 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4431 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4432 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4433 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
4434 std::string nm = get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4435 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4436 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
|
4437 if (! nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4438 os << ": " << get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4439 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4440 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4441 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4442 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4443 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4444 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4445 |
6836 | 4446 octave_value |
7189 | 4447 figure::get_default (const caseless_str& name) const |
6836 | 4448 { |
4449 octave_value retval = default_properties.lookup (name); | |
4450 | |
4451 if (retval.is_undefined ()) | |
4452 { | |
4453 graphics_handle parent = get_parent (); | |
4454 graphics_object parent_obj = gh_manager::get_object (parent); | |
4455 | |
4456 retval = parent_obj.get_default (name); | |
4457 } | |
4458 | |
4459 return retval; | |
4460 } | |
4461 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4462 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4463 figure::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4464 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
4465 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4466 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4467 |
6406 | 4468 // --------------------------------------------------------------------- |
4469 | |
8249 | 4470 void |
4471 axes::properties::init (void) | |
4472 { | |
4473 position.add_constraint (dim_vector (1, 4)); | |
4474 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
|
4475 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
|
4476 looseinset.add_constraint (dim_vector (1, 4)); |
8249 | 4477 colororder.add_constraint (dim_vector (-1, 3)); |
4478 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
4479 plotboxaspectratio.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
|
4480 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
|
4481 clim.add_constraint (2); |
8249 | 4482 xlim.add_constraint (2); |
4483 ylim.add_constraint (2); | |
4484 zlim.add_constraint (2); | |
4485 xtick.add_constraint (dim_vector (1, -1)); | |
4486 ytick.add_constraint (dim_vector (1, -1)); | |
4487 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
|
4488 ticklength.add_constraint (dim_vector (1, 2)); |
8249 | 4489 Matrix vw (1, 2, 0); |
4490 vw(1) = 90; | |
4491 view = vw; | |
4492 view.add_constraint (dim_vector (1, 2)); | |
4493 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
|
4494 cameratarget.add_constraint (dim_vector (1, 3)); |
8249 | 4495 Matrix upv (1, 3, 0.0); |
4496 upv(2) = 1.0; | |
4497 cameraupvector = upv; | |
4498 cameraupvector.add_constraint (dim_vector (1, 3)); | |
4499 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
|
4500 // 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
|
4501 update_font (); |
8249 | 4502 |
4503 x_zlim.resize (1, 2); | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4504 |
8249 | 4505 sx = "linear"; |
4506 sy = "linear"; | |
4507 sz = "linear"; | |
4508 | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4509 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4510 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4511 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4512 |
8249 | 4513 xset (xlabel.handle_value (), "handlevisibility", "off"); |
4514 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
4515 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
4516 xset (title.handle_value (), "handlevisibility", "off"); | |
4517 | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4518 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
|
4519 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4520 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
|
4521 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4522 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
|
4523 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4524 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
|
4525 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4526 |
16204
92f8bfae9b13
Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents:
16201
diff
changeset
|
4527 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
|
4528 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4529 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
|
4530 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4531 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
|
4532 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4533 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4534 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
|
4535 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
|
4536 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4537 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4538 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4539 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4540 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4541 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4542 xset (title.handle_value (), "clipping", "off"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
4543 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4544 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
|
4545 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
|
4546 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
|
4547 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
|
4548 |
8249 | 4549 adopt (xlabel.handle_value ()); |
4550 adopt (ylabel.handle_value ()); | |
4551 adopt (zlabel.handle_value ()); | |
4552 adopt (title.handle_value ()); | |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4553 |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4554 Matrix tlooseinset = default_axes_position (); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4555 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4556 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4557 looseinset = tlooseinset; |
8249 | 4558 } |
4559 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4560 Matrix |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4561 axes::properties::calc_tightbox (const Matrix& init_pos) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4562 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4563 Matrix pos = init_pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4564 graphics_object obj = gh_manager::get_object (get_parent ()); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4565 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
4566 Matrix ext = get_extent (true, true); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4567 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
|
4568 ext(0)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4569 ext(1)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4570 ext = convert_position (ext, "pixels", get_units (), |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4571 parent_bb.extract_n (0, 2, 1, 2)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4572 if (ext(0) < pos(0)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4573 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4574 pos(2) += pos(0)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4575 pos(0) = ext(0); |
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 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
|
4578 pos(2) = ext(0)+ext(2)-pos(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4579 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4580 if (ext(1) < pos(1)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4581 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4582 pos(3) += pos(1)-ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4583 pos(1) = ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4584 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4585 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
|
4586 pos(3) = ext(1)+ext(3)-pos(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4587 return pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4588 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
4589 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4590 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
|
4591 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
|
4592 { |
17011
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4593 // 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
|
4594 if (activepositionproperty.is ("position")) |
283422a219a2
Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17192
diff
changeset
|
4595 update_position (); |
283422a219a2
Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17192
diff
changeset
|
4596 else |
283422a219a2
Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17192
diff
changeset
|
4597 update_outerposition (); |
17011
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4598 caseless_str old_units = get_units (); |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4599 set_units ("normalized"); |
16832
e528beb2d774
Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents:
16831
diff
changeset
|
4600 Matrix pos = position.get ().matrix_value (); |
e528beb2d774
Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents:
16831
diff
changeset
|
4601 Matrix outpos = outerposition.get ().matrix_value (); |
e528beb2d774
Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents:
16831
diff
changeset
|
4602 Matrix tightpos = calc_tightbox (pos); |
17011
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4603 Matrix tinset (1, 4, 1.0); |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4604 tinset(0) = pos(0)-tightpos(0); |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4605 tinset(1) = pos(1)-tightpos(1); |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4606 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
|
4607 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
|
4608 tightinset = tinset; |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4609 set_units (old_units); |
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4610 update_transform (); |
17260
92effb035b97
Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17237
diff
changeset
|
4611 if (activepositionproperty.is ("position")) |
92effb035b97
Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17237
diff
changeset
|
4612 update_position (); |
92effb035b97
Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17237
diff
changeset
|
4613 else |
92effb035b97
Update axes position/outerpostion before and after tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17237
diff
changeset
|
4614 update_outerposition (); |
17011
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4615 } |
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
|
4616 |
17024
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4617 /* |
17286
d5efffe5a789
graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents:
17281
diff
changeset
|
4618 %!testif HAVE_FLTK |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4619 %! hf = figure ("visible", "off"); |
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4620 %! graphics_toolkit (hf, "fltk"); |
17024
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4621 %! unwind_protect |
17150
e7723410ec32
Recode some %!tests which pop up figures with new figure() behavior.
Rik <rik@octave.org>
parents:
17123
diff
changeset
|
4622 %! 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
|
4623 %! hax = findall (gcf (), "type", "axes"); |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4624 %! positions = cell2mat (get (hax, "position")); |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4625 %! outerpositions = cell2mat (get (hax, "outerposition")); |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4626 %! looseinsets = cell2mat (get (hax, "looseinset")); |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4627 %! 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
|
4628 %! 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
|
4629 %! hax = findall (gcf (), "type", "axes"); |
17216
283422a219a2
Update axes position/outerpostion prior to calcuating tightinset.
Ben Abbott <bpabbott@mac.com>
parents:
17192
diff
changeset
|
4630 %! 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
|
4631 %! 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
|
4632 %! 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
|
4633 %! 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
|
4634 %! unwind_protect_cleanup |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4635 %! close (hf); |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4636 %! end_unwind_protect |
17286
d5efffe5a789
graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents:
17281
diff
changeset
|
4637 %!testif HAVE_FLTK |
17222
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4638 %! hf = figure ("visible", "off"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4639 %! graphics_toolkit (hf, "fltk"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4640 %! fpos = get (hf, "position"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4641 %! unwind_protect |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4642 %! plot (rand (3)) |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4643 %! position = get (gca, "position"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4644 %! outerposition = get (gca, "outerposition"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4645 %! looseinset = get (gca, "looseinset"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4646 %! tightinset = get (gca, "tightinset"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4647 %! 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
|
4648 %! set (hf, "position", fpos); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4649 %! 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
|
4650 %! 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
|
4651 %! 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
|
4652 %! 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
|
4653 %! unwind_protect_cleanup |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4654 %! close (hf); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4655 %! end_unwind_protect |
17286
d5efffe5a789
graphics.cc: Condition tests on HAVE_FLTK
Mike Miller <mtmiller@ieee.org>
parents:
17281
diff
changeset
|
4656 %!testif HAVE_FLTK |
17222
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4657 %! hf = figure ("visible", "off"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4658 %! graphics_toolkit (hf, "fltk"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4659 %! fpos = get (hf, "position"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4660 %! set (gca, "activepositionproperty", "position") |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4661 %! unwind_protect |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4662 %! plot (rand (3)) |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4663 %! position = get (gca, "position"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4664 %! outerposition = get (gca, "outerposition"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4665 %! looseinset = get (gca, "looseinset"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4666 %! tightinset = get (gca, "tightinset"); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4667 %! 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
|
4668 %! set (hf, "position", fpos); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4669 %! 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
|
4670 %! 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
|
4671 %! 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
|
4672 %! 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
|
4673 %! unwind_protect_cleanup |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4674 %! close (hf); |
8e196132bbea
Tests for for updating axes properties when figure position changes.
Ben Abbott <bpabbott@mac.com>
parents:
17216
diff
changeset
|
4675 %! end_unwind_protect |
17024
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4676 */ |
c358c6e7416b
Add test to graphics.cc for initial tightinset value.
Ben Abbott <bpabbott@mac.com>
parents:
17011
diff
changeset
|
4677 |
7363 | 4678 void |
8249 | 4679 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
|
4680 const std::string& who, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4681 const octave_value& v) |
6962 | 4682 { |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4683 graphics_handle val; |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4684 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4685 if (v.is_string ()) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4686 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4687 val = 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
|
4688 false, false); |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4689 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4690 xset (val, "string", v); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4691 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4692 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4693 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4694 graphics_object go = gh_manager::get_object (gh_manager::lookup (v)); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4695 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4696 if (go.isa ("text")) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4697 val = ::reparent (v, "set", who, __myhandle__, false); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4698 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4699 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4700 std::string cname = v.class_name (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4701 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4702 error ("set: expecting text graphics object or character string for %s property, found %s", |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4703 who.c_str (), cname.c_str ()); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4704 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
4705 } |
6962 | 4706 |
6874 | 4707 if (! error_state) |
4708 { | |
8249 | 4709 xset (val, "handlevisibility", "off"); |
4710 | |
4711 gh_manager::free (hp.handle_value ()); | |
4712 | |
4713 base_properties::remove_child (hp.handle_value ()); | |
4714 | |
4715 hp = val; | |
4716 | |
4717 adopt (hp.handle_value ()); | |
6874 | 4718 } |
4719 } | |
4720 | |
4721 void | |
7363 | 4722 axes::properties::set_xlabel (const octave_value& v) |
6874 | 4723 { |
8249 | 4724 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
|
4725 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
|
4726 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
|
4727 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
|
4728 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
|
4729 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
|
4730 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
|
4731 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
|
4732 update_xlabel_position (); |
6874 | 4733 } |
4734 | |
4735 void | |
7363 | 4736 axes::properties::set_ylabel (const octave_value& v) |
6874 | 4737 { |
8249 | 4738 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
|
4739 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
|
4740 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
|
4741 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
|
4742 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
|
4743 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
|
4744 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
|
4745 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
|
4746 update_ylabel_position (); |
6874 | 4747 } |
4748 | |
4749 void | |
7363 | 4750 axes::properties::set_zlabel (const octave_value& v) |
6874 | 4751 { |
8249 | 4752 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
|
4753 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
|
4754 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
|
4755 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
|
4756 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
|
4757 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
|
4758 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
|
4759 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
|
4760 update_zlabel_position (); |
8249 | 4761 } |
4762 | |
4763 void | |
4764 axes::properties::set_title (const octave_value& v) | |
4765 { | |
4766 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
|
4767 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
|
4768 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
|
4769 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
|
4770 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
|
4771 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
|
4772 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
|
4773 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
|
4774 update_title_position (); |
6874 | 4775 } |
4776 | |
4777 void | |
6844 | 4778 axes::properties::set_defaults (base_graphics_object& obj, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4779 const std::string& mode) |
6705 | 4780 { |
4781 box = "on"; | |
6962 | 4782 colororder = default_colororder (); |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4783 // Note: dataspectratio will be set through update_aspectratios |
6705 | 4784 dataaspectratiomode = "auto"; |
7363 | 4785 layer = "bottom"; |
6705 | 4786 |
4787 Matrix tlim (1, 2, 0.0); | |
4788 tlim(1) = 1; | |
4789 xlim = tlim; | |
4790 ylim = tlim; | |
4791 zlim = tlim; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4792 |
6807 | 4793 Matrix cl (1, 2, 0); |
4794 cl(1) = 1; | |
4795 clim = cl; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4796 |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4797 alim = tlim; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4798 |
7363 | 4799 xlimmode = "auto"; |
4800 ylimmode = "auto"; | |
4801 zlimmode = "auto"; | |
4802 climmode = "auto"; | |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4803 alimmode = "auto"; |
8208 | 4804 |
6705 | 4805 xgrid = "off"; |
4806 ygrid = "off"; | |
4807 zgrid = "off"; | |
4808 xminorgrid = "off"; | |
4809 yminorgrid = "off"; | |
4810 zminorgrid = "off"; | |
4811 xtick = Matrix (); | |
4812 ytick = Matrix (); | |
4813 ztick = Matrix (); | |
4814 xtickmode = "auto"; | |
4815 ytickmode = "auto"; | |
4816 ztickmode = "auto"; | |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4817 xminortick = "off"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4818 yminortick = "off"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4819 zminortick = "off"; |
6705 | 4820 xticklabel = ""; |
4821 yticklabel = ""; | |
4822 zticklabel = ""; | |
4823 xticklabelmode = "auto"; | |
4824 yticklabelmode = "auto"; | |
4825 zticklabelmode = "auto"; | |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4826 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4827 interpreter = "none"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4828 |
14798
fce841c941a5
The color property for new plot axes should take on the default value.
Ben Abbott <bpabbott@mac.com>
parents:
14691
diff
changeset
|
4829 color = color_values ("white"); |
7364 | 4830 xcolor = color_values ("black"); |
4831 ycolor = color_values ("black"); | |
4832 zcolor = color_values ("black"); | |
7363 | 4833 xscale = "linear"; |
4834 yscale = "linear"; | |
4835 zscale = "linear"; | |
6705 | 4836 xdir = "normal"; |
4837 ydir = "normal"; | |
4838 zdir = "normal"; | |
7363 | 4839 yaxislocation = "left"; |
4840 xaxislocation = "bottom"; | |
6705 | 4841 |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4842 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
|
4843 tview(1) = 90; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4844 view = tview; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4845 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4846 __hold_all__ = "off"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4847 nextplot = "replace"; |
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 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
|
4850 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4851 // Note: camera properties (not mode) will be set in update_transform |
7427 | 4852 camerapositionmode = "auto"; |
4853 cameratargetmode = "auto"; | |
4854 cameraupvectormode = "auto"; | |
4855 cameraviewanglemode = "auto"; | |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4856 |
7427 | 4857 drawmode = "normal"; |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4858 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4859 fontangle = "normal"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4860 fontname = OCTAVE_DEFAULT_FONTNAME; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4861 fontsize = 10; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4862 fontunits = "points"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4863 fontweight = "normal"; |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4864 |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4865 gridlinestyle = ":"; |
7427 | 4866 linestyleorder = "-"; |
4867 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4868 minorgridlinestyle = ":"; |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4869 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4870 // Note: plotboxaspectratio will be set through update_aspectratios |
7427 | 4871 plotboxaspectratiomode = "auto"; |
4872 projection = "orthographic"; | |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4873 |
7427 | 4874 tickdir = "in"; |
4875 tickdirmode = "auto"; | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
4876 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
|
4877 |
7427 | 4878 tightinset = Matrix (1, 4, 0.0); |
4879 | |
4880 sx = "linear"; | |
4881 sy = "linear"; | |
4882 sz = "linear"; | |
4883 | |
6765 | 4884 visible = "on"; |
17081
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4885 |
86067af51d5e
Truly reset axes so that all properties are set to default.
Rik <rik@octave.org>
parents:
17024
diff
changeset
|
4886 // Replace preserves Position and Units properties |
6705 | 4887 if (mode != "replace") |
4888 { | |
16832
e528beb2d774
Initialization and updating of tightinset and looseinset properties.
Ben Abbott <bpabbott@mac.com>
parents:
16831
diff
changeset
|
4889 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
|
4890 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
|
4891 activepositionproperty = "outerposition"; |
6406 | 4892 } |
4893 | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4894 delete_children (true); |
6432 | 4895 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4896 xlabel = 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
|
4897 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4898 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4899 ylabel = 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
|
4900 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4901 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4902 zlabel = 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
|
4903 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4904 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4905 title = 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
|
4906 false, false); |
8249 | 4907 |
4908 xset (xlabel.handle_value (), "handlevisibility", "off"); | |
4909 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
4910 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
4911 xset (title.handle_value (), "handlevisibility", "off"); | |
4912 | |
8636 | 4913 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
|
4914 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4915 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
|
4916 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4917 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
|
4918 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4919 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
|
4920 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4921 |
16204
92f8bfae9b13
Set default xlabel "verticalalignment" to "top".
Rik <rik@octave.org>
parents:
16201
diff
changeset
|
4922 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
|
4923 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4924 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
|
4925 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4926 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
|
4927 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4928 |
4929 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
|
4930 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
|
4931 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4932 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4933 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4934 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4935 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4936 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4937 xset (title.handle_value (), "clipping", "off"); |
8636 | 4938 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4939 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
|
4940 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
|
4941 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
|
4942 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
|
4943 |
8249 | 4944 adopt (xlabel.handle_value ()); |
4945 adopt (ylabel.handle_value ()); | |
4946 adopt (zlabel.handle_value ()); | |
4947 adopt (title.handle_value ()); | |
4948 | |
7427 | 4949 update_transform (); |
17011
350cad34b0f8
Simplify syncing axes "position", "outerposition", and "looseinset".
Ben Abbott <bpabbott@mac.com>
parents:
16971
diff
changeset
|
4950 sync_positions (); |
6705 | 4951 override_defaults (obj); |
4952 } | |
4953 | |
8208 | 4954 void |
4955 axes::properties::delete_text_child (handle_property& hp) | |
6874 | 4956 { |
8208 | 4957 graphics_handle h = hp.handle_value (); |
4958 | |
4959 if (h.ok ()) | |
4960 { | |
4961 graphics_object go = gh_manager::get_object (h); | |
4962 | |
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 | 4965 |
4966 base_properties::remove_child (h); | |
8208 | 4967 } |
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 | 4970 // being deleted now? I think this function is only called when an |
4971 // individual child object is delete and not when the parent axes | |
4972 // object is deleted. | |
4973 | |
8208 | 4974 if (! is_beingdeleted ()) |
8249 | 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 | 4978 |
4979 xset (hp.handle_value (), "handlevisibility", "off"); | |
4980 | |
4981 adopt (hp.handle_value ()); | |
4982 } | |
6705 | 4983 } |
6406 | 4984 |
6705 | 4985 void |
6844 | 4986 axes::properties::remove_child (const graphics_handle& h) |
6705 | 4987 { |
8249 | 4988 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
19081
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
4989 { |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
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:
18970
diff
changeset
|
4991 update_xlabel_position (); |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
4992 } |
7363 | 4993 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
19081
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
4994 { |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
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:
18970
diff
changeset
|
4996 update_ylabel_position (); |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
4997 } |
7363 | 4998 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
19081
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
4999 { |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
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:
18970
diff
changeset
|
5001 update_zlabel_position (); |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
5002 } |
8249 | 5003 else if (title.handle_value ().ok () && h == title.handle_value ()) |
19081
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
5004 { |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
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:
18970
diff
changeset
|
5006 update_title_position (); |
284f7fa221e9
Fix new x/y/zlabel position after deletion (bug #42652)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18970
diff
changeset
|
5007 } |
6705 | 5008 else |
5009 base_properties::remove_child (h); | |
5010 } | |
6406 | 5011 |
7427 | 5012 inline Matrix |
5013 xform_matrix (void) | |
5014 { | |
5015 Matrix m (4, 4, 0.0); | |
5016 for (int i = 0; i < 4; i++) | |
5017 m(i,i) = 1; | |
5018 return m; | |
5019 } | |
5020 | |
5021 inline ColumnVector | |
5022 xform_vector (void) | |
5023 { | |
5024 ColumnVector v (4, 0.0); | |
5025 v(3) = 1; | |
5026 return v; | |
5027 } | |
5028 | |
5029 inline ColumnVector | |
5030 xform_vector (double x, double y, double z) | |
5031 { | |
5032 ColumnVector v (4, 1.0); | |
5033 v(0) = x; v(1) = y; v(2) = z; | |
5034 return v; | |
5035 } | |
5036 | |
5037 inline ColumnVector | |
5038 transform (const Matrix& m, double x, double y, double z) | |
5039 { | |
5040 return (m * xform_vector (x, y, z)); | |
5041 } | |
5042 | |
5043 inline Matrix | |
5044 xform_scale (double x, double y, double z) | |
5045 { | |
5046 Matrix m (4, 4, 0.0); | |
5047 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
5048 return m; | |
5049 } | |
5050 | |
5051 inline Matrix | |
5052 xform_translate (double x, double y, double z) | |
5053 { | |
5054 Matrix m = xform_matrix (); | |
5055 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
5056 return m; | |
5057 } | |
5058 | |
5059 inline void | |
5060 scale (Matrix& m, double x, double y, double z) | |
5061 { | |
5062 m = m * xform_scale (x, y, z); | |
5063 } | |
5064 | |
5065 inline void | |
5066 translate (Matrix& m, double x, double y, double z) | |
5067 { | |
5068 m = m * xform_translate (x, y, z); | |
5069 } | |
5070 | |
5071 inline void | |
5072 xform (ColumnVector& v, const Matrix& m) | |
5073 { | |
5074 v = m*v; | |
5075 } | |
5076 | |
5077 inline void | |
5078 scale (ColumnVector& v, double x, double y, double z) | |
5079 { | |
5080 v(0) *= x; | |
5081 v(1) *= y; | |
5082 v(2) *= z; | |
5083 } | |
5084 | |
5085 inline void | |
5086 translate (ColumnVector& v, double x, double y, double z) | |
5087 { | |
5088 v(0) += x; | |
5089 v(1) += y; | |
5090 v(2) += z; | |
5091 } | |
5092 | |
5093 inline void | |
5094 normalize (ColumnVector& v) | |
5095 { | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5096 double fact = 1.0 / sqrt (v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); |
7427 | 5097 scale (v, fact, fact, fact); |
5098 } | |
5099 | |
5100 inline double | |
5101 dot (const ColumnVector& v1, const ColumnVector& v2) | |
5102 { | |
5103 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
5104 } | |
5105 | |
5106 inline double | |
5107 norm (const ColumnVector& v) | |
5108 { | |
5109 return sqrt (dot (v, v)); | |
5110 } | |
5111 | |
5112 inline ColumnVector | |
5113 cross (const ColumnVector& v1, const ColumnVector& v2) | |
5114 { | |
5115 ColumnVector r = xform_vector (); | |
5116 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
5117 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
5118 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
5119 return r; | |
5120 } | |
5121 | |
5122 inline Matrix | |
5123 unit_cube (void) | |
5124 { | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5125 static double data[32] = |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5126 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5127 0,0,0,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5128 1,0,0,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5129 0,1,0,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5130 0,0,1,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5131 1,1,0,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5132 1,0,1,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5133 0,1,1,1, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5134 1,1,1,1 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5135 }; |
7427 | 5136 Matrix m (4, 8); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5137 memcpy (m.fortran_vec (), data, sizeof (double)*32); |
7427 | 5138 return m; |
5139 } | |
5140 | |
5141 inline ColumnVector | |
5142 cam2xform (const Array<double>& m) | |
5143 { | |
5144 ColumnVector retval (4, 1.0); | |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5145 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof (double)*3); |
7427 | 5146 return retval; |
5147 } | |
5148 | |
5149 inline RowVector | |
5150 xform2cam (const ColumnVector& v) | |
5151 { | |
5152 return v.extract_n (0, 3).transpose (); | |
5153 } | |
5154 | |
5155 void | |
5156 axes::properties::update_camera (void) | |
5157 { | |
5158 double xd = (xdir_is ("normal") ? 1 : -1); | |
5159 double yd = (ydir_is ("normal") ? 1 : -1); | |
5160 double zd = (zdir_is ("normal") ? 1 : -1); | |
5161 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5162 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
|
5163 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
|
5164 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
|
5165 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5166 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
|
5167 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
|
5168 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
|
5169 |
17564
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
5170 Matrix pb = get_plotboxaspectratio ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5171 |
7427 | 5172 bool autocam = (camerapositionmode_is ("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5173 && cameratargetmode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5174 && cameraupvectormode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5175 && 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
|
5176 bool dowarp = (autocam && dataaspectratiomode_is ("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5177 && plotboxaspectratiomode_is ("auto")); |
7427 | 5178 |
5179 ColumnVector c_eye (xform_vector ()); | |
5180 ColumnVector c_center (xform_vector ()); | |
5181 ColumnVector c_upv (xform_vector ()); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5182 |
7427 | 5183 if (cameratargetmode_is ("auto")) |
5184 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5185 c_center(0) = (xlimits(0)+xlimits(1))/2; |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5186 c_center(1) = (ylimits(0)+ylimits(1))/2; |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5187 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 5188 |
5189 cameratarget = xform2cam (c_center); | |
5190 } | |
5191 else | |
5192 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
|
5193 |
7427 | 5194 if (camerapositionmode_is ("auto")) |
5195 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5196 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
|
5197 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
|
5198 double el = tview(1); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5199 double d = 5 * sqrt (pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
7427 | 5200 |
5201 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
|
5202 c_eye(2) = d*signum (el); |
7427 | 5203 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5204 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5205 az *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5206 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
|
5207 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
|
5208 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
|
5209 c_eye(2) = d * sin (el); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5210 } |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5211 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
|
5212 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
|
5213 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 5214 |
5215 cameraposition = xform2cam (c_eye); | |
5216 } | |
5217 else | |
5218 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
5219 | |
5220 if (cameraupvectormode_is ("auto")) | |
5221 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5222 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
|
5223 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
|
5224 double el = tview(1); |
7427 | 5225 |
5226 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5227 { |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
5228 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
|
5229 -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
|
5230 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
|
5231 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
|
5232 } |
7427 | 5233 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5234 c_upv(2) = 1; |
7427 | 5235 |
5236 cameraupvector = xform2cam (c_upv); | |
5237 } | |
5238 else | |
5239 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
5240 | |
5241 Matrix x_view = xform_matrix (); | |
5242 Matrix x_projection = xform_matrix (); | |
5243 Matrix x_viewport = xform_matrix (); | |
5244 Matrix x_normrender = xform_matrix (); | |
5245 Matrix x_pre = xform_matrix (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5246 |
7427 | 5247 x_render = xform_matrix (); |
5248 x_render_inv = xform_matrix (); | |
5249 | |
5250 scale (x_pre, pb(0), pb(1), pb(2)); | |
5251 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
|
5252 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
|
5253 zd/(zlimits(1)-zlimits(0))); |
7427 | 5254 translate (x_pre, -xo, -yo, -zo); |
5255 | |
5256 xform (c_eye, x_pre); | |
5257 xform (c_center, x_pre); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5258 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
|
5259 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 5260 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
5261 | |
5262 ColumnVector F (c_center), f (F), UP (c_upv); | |
5263 normalize (f); | |
5264 normalize (UP); | |
5265 | |
7440 | 5266 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 5267 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5268 double fa = 1 / sqrt(1-f(2)*f(2)); |
7427 | 5269 scale (UP, fa, fa, fa); |
5270 } | |
5271 | |
5272 ColumnVector s = cross (f, UP); | |
5273 ColumnVector u = cross (s, f); | |
5274 | |
5275 scale (x_view, 1, 1, -1); | |
5276 Matrix l = xform_matrix (); | |
5277 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
5278 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
5279 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
5280 x_view = x_view * l; | |
5281 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
5282 scale (x_view, pb(0), pb(1), pb(2)); | |
5283 translate (x_view, -0.5, -0.5, -0.5); | |
5284 | |
5285 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
|
5286 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
|
5287 ColumnVector cmax = x_cube.row_max (); |
7427 | 5288 double xM = cmax(0)-cmin(0); |
5289 double yM = cmax(1)-cmin(1); | |
5290 | |
7447 | 5291 Matrix bb = get_boundingbox (true); |
7427 | 5292 |
5293 double v_angle; | |
5294 | |
5295 if (cameraviewanglemode_is ("auto")) | |
5296 { | |
5297 double af; | |
5298 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5299 // FIXME: was this really needed? When compared to Matlab, it |
7427 | 5300 // 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
|
5301 // graphics toolkit to see results visually. |
7427 | 5302 if (false && dowarp) |
5303 af = 1.0 / (xM > yM ? xM : yM); | |
5304 else | |
5305 { | |
5306 if ((bb(2)/bb(3)) > (xM/yM)) | |
5307 af = 1.0 / yM; | |
5308 else | |
5309 af = 1.0 / xM; | |
5310 } | |
5311 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
5312 | |
5313 cameraviewangle = v_angle; | |
5314 } | |
5315 else | |
5316 v_angle = get_cameraviewangle (); | |
5317 | |
5318 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
5319 scale (x_projection, pf, pf, 1); | |
5320 | |
5321 if (dowarp) | |
5322 { | |
5323 xM *= pf; | |
5324 yM *= pf; | |
7447 | 5325 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 5326 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
5327 } | |
5328 else | |
5329 { | |
5330 double pix = 1; | |
5331 if (autocam) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5332 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5333 if ((bb(2)/bb(3)) > (xM/yM)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5334 pix = bb(3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5335 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5336 pix = bb(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5337 } |
7427 | 5338 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5339 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); |
7447 | 5340 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 5341 scale (x_viewport, pix, -pix, 1); |
5342 } | |
5343 | |
5344 x_normrender = x_viewport * x_projection * x_view; | |
5345 | |
5346 x_cube = x_normrender * unit_cube (); | |
5347 cmin = x_cube.row_min (); | |
5348 cmax = x_cube.row_max (); | |
5349 x_zlim.resize (1, 2); | |
5350 x_zlim(0) = cmin(2); | |
5351 x_zlim(1) = cmax(2); | |
5352 | |
5353 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
|
5354 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
|
5355 zd/(zlimits(1)-zlimits(0))); |
7427 | 5356 translate (x_render, -xo, -yo, -zo); |
5357 | |
5358 x_viewtransform = x_view; | |
5359 x_projectiontransform = x_projection; | |
5360 x_viewporttransform = x_viewport; | |
5361 x_normrendertransform = x_normrender; | |
5362 x_rendertransform = x_render; | |
5363 | |
5364 x_render_inv = x_render.inverse (); | |
5365 | |
5366 // Note: these matrices are a slight modified version of the regular | |
5367 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
5368 // => x_gl_mat2) | |
5369 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
|
5370 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
|
5371 zd/(zlimits(1)-zlimits(0))); |
7427 | 5372 translate (x_gl_mat1, -xo, -yo, -zo); |
5373 x_gl_mat2 = x_viewport * x_projection; | |
5374 } | |
5375 | |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5376 static bool updating_axes_layout = false; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5377 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5378 void |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5379 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
|
5380 { |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5381 if (updating_axes_layout) |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5382 return; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5383 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5384 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
|
5385 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5386 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
|
5387 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
|
5388 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
|
5389 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5390 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
|
5391 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
|
5392 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
|
5393 |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5394 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
|
5395 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
|
5396 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
|
5397 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
|
5398 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5399 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
|
5400 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5401 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
|
5402 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5403 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
|
5404 p2 = xform.transform (x_max, (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
|
5405 dir(0) = xround (p2(0)-p1(0)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5406 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5407 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5408 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
|
5409 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
|
5410 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
|
5411 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5412 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
|
5413 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
|
5414 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
|
5415 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
|
5416 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5417 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5418 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5419 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5420 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5421 xPlane = (dir(0) > 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5422 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5423 xPlane = (dir(1) < 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5424 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5425 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5426 xPlane = (dir(2) < 0 ? x_min : x_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5427 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5428 xPlaneN = (xPlane == x_min ? x_max : x_min); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5429 fx = (x_max-x_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
|
5430 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5431 p1 = xform.transform ((x_min+x_max)/2, y_min, (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
|
5432 p2 = xform.transform ((x_min+x_max)/2, y_max, (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
|
5433 dir(0) = xround (p2(0)-p1(0)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5434 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5435 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5436 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
|
5437 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
|
5438 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
|
5439 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5440 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
|
5441 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
|
5442 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
|
5443 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
|
5444 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5445 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5446 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5447 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5448 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5449 yPlane = (dir(0) > 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5450 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5451 yPlane = (dir(1) < 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5452 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5453 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5454 yPlane = (dir(2) < 0 ? y_min : y_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5455 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5456 yPlaneN = (yPlane == y_min ? y_max : y_min); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5457 fy = (y_max-y_min) / sqrt (dir(0)*dir(0)+dir(1)*dir(1)); |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5458 |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5459 p1 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5460 p2 = xform.transform ((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5461 dir(0) = xround (p2(0)-p1(0)); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5462 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5463 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5464 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
|
5465 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
|
5466 else if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5467 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5468 if (dir(0) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5469 zstate = AXE_VERT_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5470 else if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5471 zstate = AXE_HORZ_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5472 } |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5473 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5474 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5475 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5476 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5477 zPlane = (dir(0) > 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5478 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5479 zPlane = (dir(1) < 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5480 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5481 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5482 zPlane = (dir(2) < 0 ? z_min : z_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5483 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5484 zPlaneN = (zPlane == z_min ? z_max : z_min); |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5485 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
|
5486 |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5487 unwind_protect frame; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5488 frame.protect_var (updating_axes_layout); |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5489 updating_axes_layout = true; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
5490 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5491 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
|
5492 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
|
5493 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
|
5494 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
|
5495 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
|
5496 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
|
5497 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
|
5498 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
|
5499 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
|
5500 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5501 /* 2D mode */ |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5502 x2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5503 y2Dright = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5504 layer2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5505 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
|
5506 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5507 if (xaxislocation_is ("top")) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5508 { |
18832
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18822
diff
changeset
|
5509 std::swap (yPlane, yPlaneN); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5510 x2Dtop = true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5511 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5512 ypTick = yPlaneN; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5513 ypTickN = yPlane; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5514 if (yaxislocation_is ("right")) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5515 { |
18832
f684f7075aee
Don't fetch lots of axes state information for rendering if object is not visible.
Rik <rik@octave.org>
parents:
18822
diff
changeset
|
5516 std::swap (xPlane, xPlaneN); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5517 y2Dright = true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5518 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5519 xpTick = xPlaneN; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5520 xpTickN = xPlane; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5521 if (layer_is ("top")) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5522 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5523 zpTick = zPlaneN; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5524 layer2Dtop = true; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5525 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5526 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5527 zpTick = zPlane; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5528 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5529 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5530 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
|
5531 nearhoriz = std::abs (viewmat(1)) <= 5; |
18822
e42843ceff48
Fix axes bounding box not obeying 'layer' property.
Rik <rik@octave.org>
parents:
18801
diff
changeset
|
5532 is2D = viewmat(1) == 90; |
13830
462b5f556346
avoid uninitialized variable warning from valgrind
John W. Eaton <jwe@octave.org>
parents:
13816
diff
changeset
|
5533 |
14391
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5534 update_ticklength (); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5535 } |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5536 |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5537 void |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5538 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
|
5539 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5540 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
|
5541 (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
|
5542 (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
|
5543 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5544 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
|
5545 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
|
5546 |
e41e538e9d03
Fix TickDir handling for 2D and 3D plots (bug #35575).
Rik <octave@nomad.inbox5.com>
parents:
14391
diff
changeset
|
5547 double ticksign = (tickdir_is ("in") ? -1 : 1); |
14391
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5548 |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5549 Matrix bbox = get_boundingbox (true); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5550 Matrix ticklen = get_ticklength ().matrix_value (); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5551 ticklen(0) = ticklen(0) * std::max (bbox(2), bbox(3)); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5552 ticklen(1) = ticklen(1) * std::max (bbox(2), bbox(3)); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5553 |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5554 xticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5555 yticklen = ticksign * (mode2d ? ticklen(0) : ticklen(1)); |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5556 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
|
5557 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5558 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
|
5559 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
|
5560 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
|
5561 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5562 update_xlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5563 update_ylabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5564 update_zlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5565 update_title_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5566 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5567 |
14391
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5568 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
5569 ## 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
|
5570 ## 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
|
5571 %!demo |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
5572 %! clf; |
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
5573 %! subplot (2,1,1); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5574 %! plot (rand (3)); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5575 %! xlabel xlabel; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5576 %! ylabel ylabel; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5577 %! title title; |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
5578 %! subplot (2,1,2); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5579 %! plot (rand (3)); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5580 %! 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
|
5581 %! xlabel xlabel; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5582 %! ylabel ylabel; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
5583 %! title title; |
14391
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5584 */ |
c9ec21bef97a
Fix ticklength updating (bug # 35438).
Ben Abbott <bpabbott@mac.com>
parents:
14367
diff
changeset
|
5585 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5586 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
|
5587 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5588 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5589 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
|
5590 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5591 if (updating_xlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5592 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5593 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5594 text::properties& xlabel_props |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5595 = reinterpret_cast<text::properties&> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5596 (gh_manager::get_object (get_xlabel ()).get_properties ()); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5597 |
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
|
5598 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
|
5599 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5600 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5601 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
|
5602 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
|
5603 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5604 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5605 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5606 if (xlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5607 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5608 xlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5609 (xstate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5610 ? "center" : (xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5611 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5612 xlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5613 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5614 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5615 if (xlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5616 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5617 xlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5618 (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
|
5619 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5620 xlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5621 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5622 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5623 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5624 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
|
5625 || 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
|
5626 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5627 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
|
5628 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5629 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
|
5630 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
|
5631 get_xticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5632 get_xlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5633 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5634 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
|
5635 double hmax = ext(1); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5636 double angle = 0; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5637 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5638 graphics_xform::xform_vector ((xpTickN+xpTick)/2, ypTick, zpTick); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5639 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5640 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
|
5641 if (tick_along_z) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5642 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
|
5643 else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5644 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
|
5645 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5646 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
|
5647 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5648 switch (xstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5649 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5650 case AXE_ANY_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5651 p(0) += (xyzSym ? wmax : -wmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5652 p(1) += hmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5653 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5654 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5655 case AXE_VERT_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5656 p(0) -= wmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5657 angle = 90; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5658 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5659 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5660 case AXE_HORZ_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5661 p(1) += (x2Dtop ? -hmax : hmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5662 break; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5663 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5664 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5665 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
|
5666 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5667 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5668 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
|
5669 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
|
5670 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5671 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5672 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
|
5673 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5674 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
|
5675 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
|
5676 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5677 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5678 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5679 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5680 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
|
5681 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5682 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5683 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
|
5684 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5685 if (updating_ylabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5686 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5687 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5688 text::properties& ylabel_props |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5689 = reinterpret_cast<text::properties&> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5690 (gh_manager::get_object (get_ylabel ()).get_properties ()); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5691 |
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
|
5692 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
|
5693 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5694 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5695 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
|
5696 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
|
5697 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5698 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5699 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5700 if (ylabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5701 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5702 ylabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5703 (ystate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5704 ? "center" : (!xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5705 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5706 ylabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5707 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5708 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5709 if (ylabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5710 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5711 ylabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5712 (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
|
5713 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5714 ylabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5715 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5716 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5717 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5718 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
|
5719 || 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
|
5720 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5721 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
|
5722 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5723 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
|
5724 |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15760
diff
changeset
|
5725 // 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
|
5726 // 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
|
5727 // 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
|
5728 // 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
|
5729 // 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
|
5730 // xlabels are from x-axis. |
2338a92e9782
Fix spacing between ylabel and y-axis (bug #38461)
Rik <rik@octave.org>
parents:
15760
diff
changeset
|
5731 // 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
|
5732 // will be off. |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5733 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
|
5734 get_yticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5735 get_ylim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5736 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5737 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
|
5738 double hmax = ext(1); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5739 double angle = 0; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5740 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5741 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5742 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5743 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
|
5744 if (tick_along_z) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5745 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
|
5746 else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5747 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
|
5748 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5749 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
|
5750 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5751 switch (ystate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5752 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5753 case AXE_ANY_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5754 p(0) += (!xyzSym ? wmax : -wmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5755 p(1) += hmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5756 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5757 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5758 case AXE_VERT_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5759 p(0) += (y2Dright ? wmax : -wmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5760 angle = 90; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5761 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5762 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5763 case AXE_HORZ_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5764 p(1) += hmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5765 break; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5766 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5767 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5768 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
|
5769 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5770 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5771 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
|
5772 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
|
5773 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5774 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5775 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
|
5776 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5777 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
|
5778 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
|
5779 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5780 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5781 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5782 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5783 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
|
5784 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5785 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5786 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
|
5787 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5788 if (updating_zlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5789 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5790 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5791 text::properties& zlabel_props |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5792 = reinterpret_cast<text::properties&> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5793 (gh_manager::get_object (get_zlabel ()).get_properties ()); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5794 |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5795 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
|
5796 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
|
5797 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5798 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5799 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
|
5800 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
|
5801 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5802 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5803 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5804 if (zlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5805 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5806 zlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5807 ((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
|
5808 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5809 zlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5810 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5811 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5812 if (zlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5813 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5814 zlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5815 (zstate == AXE_VERT_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5816 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5817 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5818 zlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5819 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5820 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5821 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5822 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
|
5823 || 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
|
5824 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5825 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
|
5826 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5827 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
|
5828 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
|
5829 get_zticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5830 get_zlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5831 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5832 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
|
5833 double hmax = ext(1); |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
5834 double angle = 0; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5835 ColumnVector p; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5836 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5837 if (xySym) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5838 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5839 p = graphics_xform::xform_vector (xPlaneN, yPlane, |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5840 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5841 if (xisinf (fy)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5842 p(0) += (signum (xPlaneN-xPlane)*fx*ztickoffset); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5843 else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5844 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
|
5845 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5846 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5847 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5848 p = graphics_xform::xform_vector (xPlane, yPlaneN, |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5849 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5850 if (xisinf (fx)) |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5851 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
|
5852 else |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5853 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
|
5854 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5855 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5856 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
|
5857 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5858 switch (zstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5859 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5860 case AXE_ANY_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5861 if (camAuto) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5862 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5863 p(0) -= wmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5864 angle = 90; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5865 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5866 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5867 // FIXME: what's the correct offset? |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5868 // |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5869 // p[0] += (!xySym ? wmax : -wmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5870 // p[1] += (zSign ? hmax : -hmax); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5871 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5872 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5873 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5874 case AXE_VERT_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5875 p(0) -= wmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5876 angle = 90; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5877 break; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5878 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5879 case AXE_HORZ_DIR: |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5880 p(1) += hmax; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5881 break; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5882 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5883 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5884 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
|
5885 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5886 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5887 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
|
5888 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
|
5889 } |
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 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
|
5892 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5893 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
|
5894 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
|
5895 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5896 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5897 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5898 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5899 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
|
5900 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5901 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5902 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
|
5903 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5904 if (updating_title_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5905 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5906 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5907 text::properties& title_props |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5908 = reinterpret_cast<text::properties&> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5909 (gh_manager::get_object (get_title ()).get_properties ()); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5910 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5911 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5912 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
|
5913 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
|
5914 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5915 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
|
5916 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5917 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
|
5918 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5919 // 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
|
5920 Matrix bbox = get_extent (false); |
13910
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5921 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5922 ColumnVector p = |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5923 graphics_xform::xform_vector (bbox(0)+bbox(2)/2, |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5924 bbox(1)-10, |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5925 (x_zlim(0)+x_zlim(1))/2); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5926 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5927 if (x2Dtop) |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5928 { |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5929 Matrix ext (1, 2, 0.0); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5930 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
|
5931 get_xticklabel ().all_strings (), |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5932 get_xlim ().matrix_value ()); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5933 p(1) -= ext(1); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5934 } |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5935 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5936 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
|
5937 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
5938 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
|
5939 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
|
5940 } |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5941 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5942 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5943 void |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5944 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
|
5945 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5946 if (elem_type == "xlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5947 update_xlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5948 else if (elem_type == "ylabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5949 update_ylabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5950 else if (elem_type == "zlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5951 update_zlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5952 else if (elem_type == "title") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5953 update_title_position (); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5954 else if (elem_type == "sync") |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5955 sync_positions (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5956 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5957 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5958 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5959 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5960 double xlength, double ylength, double zlength) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5961 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5962 double xval = xlength/scalefactors(0); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5963 double yval = ylength/scalefactors(1); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5964 double zval = zlength/scalefactors(2); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5965 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5966 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
|
5967 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5968 aspectratios(0) = xval/minval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5969 aspectratios(1) = yval/minval; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
5970 aspectratios(2) = zval/minval; |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5971 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5972 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5973 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5974 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
|
5975 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
|
5976 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5977 if (tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5978 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5979 double minval = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5980 double maxval = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5981 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5982 double max_neg = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5983 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
|
5984 if (xfinite (minval) && xfinite (maxval)) |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5985 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5986 limits(0) = minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5987 limits(1) = maxval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5988 s = xmax(s, (maxval - minval) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5989 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5990 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5991 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5992 s = xmax(s, (limits(1) - limits(0)) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5993 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5994 |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
5995 static std::set<double> updating_aspectratios; |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5996 |
7427 | 5997 void |
5998 axes::properties::update_aspectratios (void) | |
5999 { | |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
6000 if (updating_aspectratios.find (get___myhandle__ ().value ()) != |
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
6001 updating_aspectratios.end ()) |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6002 return; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6003 |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
6004 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
|
6005 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
|
6006 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
|
6007 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
6008 double dx = (xlimits(1)-xlimits(0)); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
6009 double dy = (ylimits(1)-ylimits(0)); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
6010 double dz = (zlimits(1)-zlimits(0)); |
7427 | 6011 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6012 Matrix da = get_dataaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6013 Matrix pba = get_plotboxaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6014 |
7427 | 6015 if (dataaspectratiomode_is ("auto")) |
6016 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6017 if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6018 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6019 pba = Matrix (1, 3, 1.0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6020 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6021 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6022 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6023 normalized_aspectratios (da, pba, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6024 dataaspectratio.set (da, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6025 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6026 else if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6027 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6028 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6029 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6030 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6031 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6032 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6033 double s = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6034 bool modified_limits = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6035 Matrix kids; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6036 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6037 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
|
6038 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6039 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6040 kids = get_children (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6041 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
|
6042 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
|
6043 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
|
6044 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6045 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
|
6046 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6047 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6048 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
|
6049 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6050 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
|
6051 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6052 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6053 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
|
6054 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6055 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
|
6056 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6057 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6058 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
|
6059 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6060 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6061 if (modified_limits) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6062 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6063 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6064 unwind_protect frame; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6065 frame.protect_var (updating_aspectratios); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6066 |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
6067 updating_aspectratios.insert (get___myhandle__ ().value ()); |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6068 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6069 dx = pba(0) *da(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6070 dy = pba(1) *da(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6071 dz = pba(2) *da(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6072 if (xisinf (s)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6073 s = 1 / xmin (xmin (dx, dy), dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6074 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6075 if (xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6076 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6077 dx = s * dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6078 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
|
6079 xlimits(1) = xlimits(0) + dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6080 set_xlim (xlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6081 set_xlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6082 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6083 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6084 if (ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6085 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6086 dy = s * dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6087 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
|
6088 ylimits(1) = ylimits(0) + dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6089 set_ylim (ylimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6090 set_ylimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6091 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6092 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6093 if (zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6094 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6095 dz = s * dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6096 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
|
6097 zlimits(1) = zlimits(0) + dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6098 set_zlim (zlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6099 set_zlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6100 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6101 } |
7427 | 6102 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6103 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6104 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6105 plotboxaspectratio.set (pba, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6106 } |
7427 | 6107 } |
6108 } | |
6109 | |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6110 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6111 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
|
6112 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6113 #ifdef HAVE_FREETYPE |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6114 #ifdef HAVE_FONTCONFIG |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6115 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
|
6116 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
|
6117 get ("fontangle").string_value (), |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6118 get ("fontsize").double_value ()); |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6119 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6120 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6121 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6122 |
7447 | 6123 // The INTERNAL flag defines whether position or outerposition is used. |
6124 | |
7427 | 6125 Matrix |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6126 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
|
6127 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
|
6128 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6129 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
|
6130 : 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
|
6131 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
|
6132 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6133 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6134 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6135 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6136 |
17607
07a4597fcbac
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17564
diff
changeset
|
6137 if (obj.valid_object ()) |
07a4597fcbac
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17564
diff
changeset
|
6138 parent_size = |
07a4597fcbac
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17564
diff
changeset
|
6139 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
07a4597fcbac
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17564
diff
changeset
|
6140 else |
07a4597fcbac
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17564
diff
changeset
|
6141 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
|
6142 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6143 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6144 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
|
6145 |
7427 | 6146 pos(0)--; |
6147 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
|
6148 pos(1) = parent_size(1) - pos(1) - pos(3); |
7427 | 6149 |
6150 return pos; | |
6151 } | |
6152 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6153 Matrix |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6154 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
|
6155 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6156 graphics_xform xform = get_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6157 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6158 Matrix ext (1, 4, 0.0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6159 ext(0) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6160 ext(1) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6161 ext(2) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6162 ext(3) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6163 for (int i = 0; i <= 1; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6164 for (int j = 0; j <= 1; j++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6165 for (int k = 0; k <= 1; k++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6166 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6167 ColumnVector p = xform.transform (i ? xPlaneN : xPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6168 j ? yPlaneN : yPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6169 k ? zPlaneN : zPlane, false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6170 ext(0) = std::min (ext(0), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6171 ext(1) = std::min (ext(1), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6172 ext(2) = std::max (ext(2), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6173 ext(3) = std::max (ext(3), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6174 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6175 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6176 if (with_text) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6177 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6178 for (int i = 0; i < 4; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6179 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6180 graphics_handle text_handle; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6181 if (i == 0) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6182 text_handle = get_title (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6183 else if (i == 1) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6184 text_handle = get_xlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6185 else if (i == 2) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6186 text_handle = get_ylabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6187 else if (i == 3) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6188 text_handle = get_zlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6189 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6190 text::properties& text_props |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6191 = reinterpret_cast<text::properties&> |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6192 (gh_manager::get_object (text_handle).get_properties ()); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6193 |
14483
6a736395ff7d
fix wrong axes extents for text elements with custom units (bug #35856)
Konstantinos Poulios <logari81@googlemail.com>
parents:
14457
diff
changeset
|
6194 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
|
6195 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
|
6196 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
|
6197 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
6198 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
|
6199 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
|
6200 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
|
6201 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
|
6202 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
6203 else |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6204 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6205 Matrix text_ext = text_props.get_extent_matrix (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6206 |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6207 bool ignore_horizontal = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6208 bool ignore_vertical = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6209 if (only_text_height) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6210 { |
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
|
6211 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
|
6212 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
|
6213 ignore_horizontal = true; |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6214 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
|
6215 ignore_vertical = true; |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6216 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6217 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6218 if (! ignore_horizontal) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6219 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6220 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
|
6221 ext(2) = std::max (ext(2), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6222 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
|
6223 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6224 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6225 if (! ignore_vertical) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
6226 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6227 ext(1) = std::min (ext(1), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6228 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
|
6229 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
|
6230 } |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6231 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6232 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6233 } |
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 ext(2) = ext(2)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6236 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
|
6237 |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6238 return ext; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6239 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6240 |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6241 static octave_value |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6242 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
|
6243 { |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6244 octave_value retval = val; |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6245 |
16841
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6246 if (val.is_cellstr ()) |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6247 { |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6248 // Always return a column vector for Matlab Compatibility |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6249 if (val.columns () > 1) |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6250 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
|
6251 } |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6252 else |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6253 { |
16854
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6254 string_vector sv; |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6255 if (val.is_numeric_type ()) |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6256 { |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6257 NDArray data = val.array_value (); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6258 std::ostringstream oss; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6259 oss.precision (5); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6260 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
|
6261 { |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6262 oss.str (""); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6263 oss << data(i); |
16854
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6264 sv.append (oss.str ()); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6265 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6266 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6267 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
|
6268 { |
16854
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6269 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
|
6270 std::istringstream iss (valstr); |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6271 std::string tmpstr; |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6272 |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6273 // Split string with delimiter '|' |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6274 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
|
6275 sv.append (tmpstr); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6276 |
16854
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6277 // 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
|
6278 if (*valstr.rbegin () == '|') |
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6279 sv.append (std::string ("")); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6280 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6281 else |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6282 return retval; |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6283 |
16854
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6284 charMatrix chmat (sv, ' '); |
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6285 |
563f8f0a7e29
Handle ticklabel specification with '|' the same way as Matlab (bug #39344).
Rik <rik@octave.org>
parents:
16841
diff
changeset
|
6286 retval = octave_value (chmat); |
16841
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6287 } |
2ce1ddead134
Return a cellstr column vector for ticklabels (bug #34906).
Rik <rik@octave.org>
parents:
16840
diff
changeset
|
6288 |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6289 return retval; |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6290 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6291 |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6292 void |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6293 axes::properties::set_xticklabel (const octave_value& v) |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6294 { |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6295 if (!error_state) |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6296 { |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6297 if (xticklabel.set (convert_ticklabel_string (v), false)) |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6298 { |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6299 set_xticklabelmode ("manual"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6300 xticklabel.run_listeners (POSTSET); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6301 mark_modified (); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6302 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6303 else |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6304 set_xticklabelmode ("manual"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6305 } |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6306 } |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6307 |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6308 void |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6309 axes::properties::set_yticklabel (const octave_value& v) |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6310 { |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6311 if (!error_state) |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6312 { |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6313 if (yticklabel.set (convert_ticklabel_string (v), false)) |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6314 { |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6315 set_yticklabelmode ("manual"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6316 yticklabel.run_listeners (POSTSET); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6317 mark_modified (); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6318 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6319 else |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6320 set_yticklabelmode ("manual"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6321 } |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6322 } |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6323 |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6324 void |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6325 axes::properties::set_zticklabel (const octave_value& v) |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6326 { |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6327 if (!error_state) |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6328 { |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6329 if (zticklabel.set (convert_ticklabel_string (v), false)) |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6330 { |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6331 set_zticklabelmode ("manual"); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6332 zticklabel.run_listeners (POSTSET); |
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6333 mark_modified (); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6334 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6335 else |
16840
969233a27bce
maint: Use octave coding conventions for changeset fd5a4b7f59f7.
Rik <rik@octave.org>
parents:
16832
diff
changeset
|
6336 set_zticklabelmode ("manual"); |
16750
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6337 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6338 } |
fd5a4b7f59f7
add format option to ticklabel (bug #34906)
Stefan Mahr <dac922@gmx.de>
parents:
16312
diff
changeset
|
6339 |
17382
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6340 // 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
|
6341 // cellstr or string, not numeric input. |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6342 static octave_value |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6343 convert_linestyleorder_string (const octave_value& val) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6344 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6345 octave_value retval = val; |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6346 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6347 if (val.is_cellstr ()) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6348 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6349 // 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
|
6350 if (val.columns () > 1) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6351 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
|
6352 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6353 else |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6354 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6355 string_vector sv; |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6356 if (val.is_string () && val.rows () == 1) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6357 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6358 std::string valstr = val.string_value (); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6359 std::istringstream iss (valstr); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6360 std::string tmpstr; |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6361 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6362 // Split string with delimiter '|' |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6363 while (std::getline (iss, tmpstr, '|')) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6364 sv.append (tmpstr); |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6365 |
17382
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6366 // 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
|
6367 if (*valstr.rbegin () == '|') |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6368 sv.append (std::string ("")); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6369 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6370 else |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6371 return retval; |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6372 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6373 charMatrix chmat (sv, ' '); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6374 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6375 retval = octave_value (chmat); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6376 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6377 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6378 return retval; |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6379 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6380 |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6381 void |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6382 axes::properties::set_linestyleorder (const octave_value& v) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6383 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6384 if (!error_state) |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6385 { |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6386 linestyleorder.set (convert_linestyleorder_string (v), false); |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6387 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6388 } |
50b2863d10a6
Create Matlab compatible linestyleorder char matrices (bug #34906)
Rik <rik@octave.org>
parents:
17319
diff
changeset
|
6389 |
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
|
6390 void |
19153
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6391 axes::properties::set_rotate3d (const octave_value& v) |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6392 { |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6393 rotate3d.set (v, false, false); |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6394 if (rotate3d_is ("on")) |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6395 { |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6396 // Disable rotate3d for 2D plots |
19154
d4b69559a0f7
graphics.cc (axes::properties::set_rotate3d): Fix check for 2D axes
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19153
diff
changeset
|
6397 if (get_is2D ()) |
19153
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6398 { |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6399 rotate3d.set ("off", false, false); |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6400 pan.set ("on", false, false); |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6401 } |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6402 else |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6403 pan.set ("off", false, false); |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6404 } |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6405 } |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6406 |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
6407 void |
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
|
6408 axes::properties::set_units (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6409 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6410 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6411 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6412 caseless_str old_units = get_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
|
6413 if (units.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6414 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6415 update_units (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
|
6416 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6417 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6418 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6419 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6420 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6421 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
|
6422 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
|
6423 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6424 graphics_object obj = 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
|
6425 Matrix parent_bb |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6426 = obj.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
|
6427 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
|
6428 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
|
6429 old_units, new_units, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6430 parent_bb)), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6431 false); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6432 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
|
6433 old_units, new_units, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6434 parent_bb)), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6435 false); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6436 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
|
6437 old_units, new_units, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6438 parent_bb)), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6439 false); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6440 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
|
6441 old_units, new_units, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6442 parent_bb)), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6443 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
|
6444 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6445 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6446 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
|
6447 axes::properties::set_fontunits (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6448 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6449 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6450 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6451 caseless_str old_fontunits = get_fontunits (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6452 if (fontunits.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6453 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6454 update_fontunits (old_fontunits); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6455 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6456 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6457 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6458 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6459 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6460 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
|
6461 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
|
6462 { |
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 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
|
6464 double parent_height = get_boundingbox (true).elem (3); |
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
|
6465 double fsz = 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
|
6466 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6467 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
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
|
6468 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
6469 set_fontsize (octave_value (fsz)); |
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 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6472 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6473 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
|
6474 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6475 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6476 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
|
6477 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6478 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
|
6479 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
|
6480 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6481 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6482 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6483 |
7435 | 6484 ColumnVector |
6485 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 6486 { |
6487 return ::xform_vector (x, y, z); | |
6488 } | |
7435 | 6489 |
6490 Matrix | |
6491 graphics_xform::xform_eye (void) | |
7869 | 6492 { |
6493 return ::xform_matrix (); | |
6494 } | |
7435 | 6495 |
6496 ColumnVector | |
6497 graphics_xform::transform (double x, double y, double z, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6498 bool use_scale) const |
7435 | 6499 { |
6500 if (use_scale) | |
6501 { | |
6502 x = sx.scale (x); | |
6503 y = sy.scale (y); | |
6504 z = sz.scale (z); | |
6505 } | |
6506 | |
6507 return ::transform (xform, x, y, z); | |
6508 } | |
6509 | |
6510 ColumnVector | |
6511 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
|
6512 bool use_scale) const |
7435 | 6513 { |
6514 ColumnVector v = ::transform (xform_inv, x, y, z); | |
6515 | |
6516 if (use_scale) | |
6517 { | |
6518 v(0) = sx.unscale (v(0)); | |
6519 v(1) = sy.unscale (v(1)); | |
6520 v(2) = sz.unscale (v(2)); | |
6521 } | |
6522 | |
6523 return v; | |
6524 } | |
6525 | |
6836 | 6526 octave_value |
7189 | 6527 axes::get_default (const caseless_str& name) const |
6836 | 6528 { |
6529 octave_value retval = default_properties.lookup (name); | |
6530 | |
6531 if (retval.is_undefined ()) | |
6532 { | |
6533 graphics_handle parent = get_parent (); | |
6534 graphics_object parent_obj = gh_manager::get_object (parent); | |
6535 | |
6536 retval = parent_obj.get_default (name); | |
6537 } | |
6538 | |
6539 return retval; | |
6540 } | |
6541 | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6542 // FIXME: remove. |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6543 // 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
|
6544 /* |
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
|
6545 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6546 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
|
6547 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6548 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
|
6549 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
6550 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
|
6551 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
|
6552 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
|
6553 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
|
6554 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
|
6555 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
|
6556 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
|
6557 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
|
6558 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6559 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
|
6560 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
|
6561 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
|
6562 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6563 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6564 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6565 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6566 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
|
6567 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6568 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
|
6569 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6570 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
|
6571 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6572 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
|
6573 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6574 if (! error_state && m.numel () == 4) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6575 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6576 double val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6577 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6578 val = m(0); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
6579 if (xfinite (val) && val < min_val) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6580 min_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6581 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6582 val = m(1); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
6583 if (xfinite (val) && val > max_val) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6584 max_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6585 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6586 val = m(2); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
6587 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
|
6588 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6589 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6590 val = m(3); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
6591 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
|
6592 max_neg = val; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6593 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6594 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6595 } |
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
|
6596 |
12508
919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents:
12506
diff
changeset
|
6597 // magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is |
919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents:
12506
diff
changeset
|
6598 // integer. |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6599 |
7869 | 6600 static void |
6601 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
|
6602 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6603 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6604 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6605 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6606 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6607 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6608 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6609 { |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
6610 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
|
6611 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
|
6612 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6613 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6614 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6615 // 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
|
6616 // 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
|
6617 // FIXME: add log ticks |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6618 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6619 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6620 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
|
6621 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6622 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6623 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6624 // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6625 // SCALE3 for Determination of Scales on Computer Generated |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6626 // Plots", Communications of the ACM, 10 (1973), 639-640. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6627 // 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
|
6628 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6629 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6630 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6631 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6632 magform ((hi-lo)/ticint, a, b); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6633 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6634 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
|
6635 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
|
6636 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
|
6637 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6638 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6639 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6640 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6641 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6642 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6643 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6644 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6645 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6646 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6647 return x * std::pow (10., b); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6648 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6649 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6650 |
7222 | 6651 // Attempt to make "nice" limits from the actual max and min of the |
6652 // data. For log plots, we will also use the smallest strictly positive | |
6653 // value. | |
6654 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6655 Matrix |
7869 | 6656 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
|
6657 double min_pos, double max_neg, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6658 bool logscale) |
7222 | 6659 { |
6660 Matrix retval; | |
6661 | |
6662 double min_val = xmin; | |
6663 double max_val = xmax; | |
6664 | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
6665 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
|
6666 { |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
6667 retval = default_lim (logscale); |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
6668 return retval; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
6669 } |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
6670 else if (! (xisinf (min_val) || xisinf (max_val))) |
7222 | 6671 { |
6672 if (logscale) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6673 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6674 if (xisinf (min_pos) && xisinf (max_neg)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6675 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6676 // TODO -- max_neg is needed for "loglog ([0 -Inf])" |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6677 // This is the only place where max_neg is needed. |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6678 // Is there another way? |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6679 retval = default_lim (); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6680 retval(0) = pow (10., retval(0)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6681 retval(1) = pow (10., retval(1)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6682 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6683 } |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13736
diff
changeset
|
6684 if ((min_val <= 0 && max_val > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6685 { |
14062
5b49cafe0599
Use non-negative, non-positive with hyphens in error messages.
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
6686 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
|
6687 min_val = min_pos; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6688 } |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6689 // 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
|
6690 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
|
6691 < sqrt (std::numeric_limits<double>::epsilon ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6692 { |
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
|
6693 // 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
|
6694 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
|
6695 { |
e3da2a68d709
Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents:
14604
diff
changeset
|
6696 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
|
6697 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
|
6698 } |
e3da2a68d709
Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents:
14604
diff
changeset
|
6699 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
|
6700 { |
e3da2a68d709
Fix memory exhausted bug with log plots of small negative constant data (bug #36493)
Rik <octave@nomad.inbox5.com>
parents:
14604
diff
changeset
|
6701 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
|
6702 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
|
6703 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6704 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6705 if (min_val > 0) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6706 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6707 // Log plots with all positive data |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6708 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
|
6709 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
|
6710 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6711 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6712 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6713 // 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
|
6714 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
|
6715 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
|
6716 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6717 } |
7222 | 6718 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6719 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6720 if (min_val == 0 && max_val == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6721 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6722 min_val = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6723 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6724 } |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17842
diff
changeset
|
6725 // 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
|
6726 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
|
6727 < sqrt (std::numeric_limits<double>::epsilon ())) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6728 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6729 min_val -= 0.1 * std::abs (min_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6730 max_val += 0.1 * std::abs (max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6731 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6732 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6733 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
|
6734 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
|
6735 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
|
6736 // Prevent round-off from cropping ticks |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
6737 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
|
6738 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
|
6739 } |
7222 | 6740 } |
6741 | |
6742 retval.resize (1, 2); | |
6743 | |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
6744 retval(1) = max_val; |
7222 | 6745 retval(0) = min_val; |
6746 | |
6747 return retval; | |
6748 } | |
6749 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6750 void |
7869 | 6751 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
|
6752 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
|
6753 array_property& mticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6754 bool limmode_is_auto, bool is_logscale) |
7446 | 6755 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
6756 // FIXME: add log ticks and lims |
7446 | 6757 |
6758 if (lims.get ().is_empty ()) | |
6759 return; | |
6760 | |
6761 double lo = (lims.get ().matrix_value ()) (0); | |
6762 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
|
6763 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
|
6764 double tmp; |
17861
870f3e12e163
maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents:
17842
diff
changeset
|
6765 // 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
|
6766 if (hi < lo) |
18857
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6767 std::swap (hi, lo); |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6768 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6769 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6770 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6771 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6772 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6773 tmp = hi; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6774 hi = std::log10 (-lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6775 lo = std::log10 (-tmp); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6776 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6777 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6778 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6779 hi = std::log10 (hi); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6780 lo = std::log10 (lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6781 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6782 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6783 |
18857
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6784 double tick_sep; |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6785 |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6786 if (is_logscale) |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6787 { |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6788 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:
18838
diff
changeset
|
6789 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:
18838
diff
changeset
|
6790 else |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6791 tick_sep = 0; |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6792 } |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6793 else |
ec55f6870efb
Fix incorrect log axis minor ticks when axis range > 8 orders of magnitude (bug #39449).
Rik <rik@octave.org>
parents:
18838
diff
changeset
|
6794 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
|
6795 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
6796 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
|
6797 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
|
6798 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6799 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6800 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6801 // adjust limits to include min and max tics |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6802 Matrix tmp_lims (1,2); |
12549
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
6803 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
|
6804 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
|
6805 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6806 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6807 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6808 tmp_lims(0) = std::pow (10.,tmp_lims(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6809 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
|
6810 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
|
6811 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
|
6812 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6813 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6814 tmp = tmp_lims(0); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6815 tmp_lims(0) = -tmp_lims(1); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6816 tmp_lims(1) = -tmp; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6817 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6818 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6819 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6820 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6821 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6822 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
|
6823 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
|
6824 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6825 tmp_ticks (i) = tick_sep * (i+i1); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
6826 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6827 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
|
6828 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6829 if (is_logscale && is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6830 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6831 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
|
6832 rev_ticks = -tmp_ticks; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6833 for (int i = 0; i <= i2-i1; i++) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6834 tmp_ticks (i) = rev_ticks (i2-i1-i); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6835 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6836 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
6837 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
|
6838 |
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
|
6839 int n = is_logscale ? 8 : 4; |
12157
0b9c1a7e350a
fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents:
12126
diff
changeset
|
6840 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
|
6841 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6842 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
|
6843 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6844 double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6845 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
|
6846 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6847 tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6848 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6849 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
6850 mticks = tmp_mticks; |
7446 | 6851 } |
6852 | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6853 void |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6854 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
|
6855 any_property& labels, bool logscale) |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6856 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6857 Matrix values = ticks.get ().matrix_value (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6858 Cell c (values.dims ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6859 std::ostringstream os; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6860 |
13211
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6861 if (logscale) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6862 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6863 double significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6864 double exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6865 double exp_max = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6866 double exp_min = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6867 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6868 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
|
6869 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6870 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
|
6871 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
|
6872 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6873 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6874 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
|
6875 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6876 if (values(i) < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6877 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
|
6878 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6879 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
|
6880 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
|
6881 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6882 os << significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6883 if (exponent < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6884 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6885 os << "e-"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6886 exponent = -exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6887 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6888 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6889 os << "e+"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6890 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
|
6891 os << "0"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6892 os << exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6893 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6894 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6895 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6896 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6897 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6898 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
|
6899 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6900 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6901 os << values(i); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6902 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
6903 } |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6904 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6905 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6906 labels = c; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6907 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
6908 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6909 Matrix |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6910 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
|
6911 const string_vector& ticklabels, |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6912 const Matrix& limits) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6913 { |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6914 #ifndef HAVE_FREETYPE |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6915 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
|
6916 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6917 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6918 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
|
6919 double wmax, hmax; |
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
6920 wmax = hmax = 0.; |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6921 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
|
6922 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
|
6923 { |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6924 double val = ticks(i); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6925 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
|
6926 { |
16855
359ac80ecb30
Trim ticklabel strings and repeat them as necessary to fill tick marks (bug #39344)
Rik <rik@octave.org>
parents:
16854
diff
changeset
|
6927 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
|
6928 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
|
6929 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
|
6930 #ifdef HAVE_FREETYPE |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17260
diff
changeset
|
6931 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
|
6932 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
|
6933 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
|
6934 #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
|
6935 // 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
|
6936 int len = label.length (); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6937 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
|
6938 hmax = fontsize; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6939 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6940 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6941 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6942 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6943 ext(0) = wmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6944 ext(1) = hmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6945 return ext; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6946 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
6947 |
9455 | 6948 void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6949 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
|
6950 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6951 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
|
6952 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6953 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
|
6954 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6955 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
|
6956 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6957 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
|
6958 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
|
6959 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6960 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6961 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6962 if (obj.is_xliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6963 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6964 octave_value lim = obj.get_xlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6965 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6966 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
|
6967 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6968 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6969 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6970 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6971 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
|
6972 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
|
6973 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6974 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6975 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6976 if (obj.is_yliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6977 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6978 octave_value lim = obj.get_ylim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6979 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6980 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
|
6981 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6982 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6983 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6984 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6985 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
|
6986 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
|
6987 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6988 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6989 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6990 if (obj.is_zliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6991 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6992 octave_value lim = obj.get_zlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6993 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6994 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
|
6995 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6996 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6997 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6998 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6999 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
|
7000 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
|
7001 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7002 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7003 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7004 if (obj.is_climinclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7005 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7006 octave_value lim = obj.get_clim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7007 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7008 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
|
7009 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7010 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7011 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7012 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7013 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
|
7014 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
|
7015 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7016 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7017 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7018 if (obj.is_aliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7019 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7020 octave_value lim = obj.get_alim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7021 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7022 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
|
7023 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7024 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7025 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7026 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7027 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7028 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7029 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7030 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7031 |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7032 static std::set<double> updating_axis_limits; |
7222 | 7033 |
7214 | 7034 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7035 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
|
7036 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
|
7037 { |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7038 if (updating_axis_limits.find (get_handle ().value ()) != |
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7039 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
|
7040 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7041 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7042 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
|
7043 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7044 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
|
7045 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
|
7046 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7047 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
|
7048 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7049 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
|
7050 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7051 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7052 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7053 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7054 #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
|
7055 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
|
7056 { \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7057 val = limits(0); \ |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
7058 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
|
7059 min_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7060 val = limits(1); \ |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
7061 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
|
7062 max_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7063 val = limits(2); \ |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
7064 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
|
7065 min_pos = val; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7066 val = limits(3); \ |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
7067 if (xfinite (val)) \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7068 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
|
7069 } \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7070 else \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7071 { \ |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
7072 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
|
7073 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
|
7074 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
|
7075 limits(2) = min_pos; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7076 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
|
7077 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7078 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7079 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
|
7080 || 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
|
7081 || axis_type == "xlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7082 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7083 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
|
7084 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7085 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
|
7086 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7087 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7088 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
|
7089 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7090 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
|
7091 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
|
7092 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
|
7093 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7094 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7095 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7096 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7097 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
|
7098 || 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
|
7099 || axis_type == "ylim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7100 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7101 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
|
7102 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7103 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
|
7104 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7105 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7106 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
|
7107 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7108 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
|
7109 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
|
7110 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
|
7111 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7112 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7113 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7114 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7115 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
|
7116 || 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
|
7117 || axis_type == "zlim") |
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 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
|
7120 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7121 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
|
7122 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7123 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7124 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
|
7125 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7126 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
|
7127 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
|
7128 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
|
7129 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7130 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7131 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7132 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7133 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
|
7134 || 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
|
7135 || axis_type == "clim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7136 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7137 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
|
7138 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7139 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
|
7140 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7141 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7142 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
|
7143 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7144 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
|
7145 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7146 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
|
7147 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7148 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7149 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7150 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7151 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7152 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7153 } |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7154 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7155 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
|
7156 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7157 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
|
7158 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
|
7159 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7160 update_type = 'c'; |
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 |
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 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
|
7165 || 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
|
7166 || axis_type == "alim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7167 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7168 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
|
7169 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7170 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
|
7171 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7172 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7173 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
|
7174 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7175 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
|
7176 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7177 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
|
7178 max_val = 1; |
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 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
|
7181 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
|
7182 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7183 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
|
7184 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7185 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
|
7186 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
|
7187 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7188 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7189 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7190 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7191 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7192 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7193 #undef FIX_LIMITS |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7194 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7195 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7196 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
|
7197 |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7198 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
|
7199 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7200 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7201 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7202 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7203 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
|
7204 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
|
7205 xproperties.update_xlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7206 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7207 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7208 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7209 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
|
7210 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
|
7211 xproperties.update_ylim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7212 break; |
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 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7215 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
|
7216 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
|
7217 xproperties.update_zlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7218 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7219 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7220 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7221 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
|
7222 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
|
7223 break; |
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 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7226 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
|
7227 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
|
7228 break; |
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 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7231 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7232 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7233 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7234 xproperties.update_transform (); |
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 } |
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 void |
7222 | 7239 axes::update_axis_limits (const std::string& axis_type) |
7214 | 7240 { |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7241 if ((updating_axis_limits.find (get_handle ().value ()) != |
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7242 updating_axis_limits.end ()) || |
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7243 (updating_aspectratios.find (get_handle ().value ()) != |
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7244 updating_aspectratios.end ())) |
7222 | 7245 return; |
7246 | |
7247 Matrix kids = xproperties.get_children (); | |
7248 | |
7249 double min_val = octave_Inf; | |
7250 double max_val = -octave_Inf; | |
7251 double min_pos = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7252 double max_neg = -octave_Inf; |
7222 | 7253 |
7254 char update_type = 0; | |
7255 | |
7256 Matrix limits; | |
7257 | |
7258 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
|
7259 || 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
|
7260 || axis_type == "xlim") |
7222 | 7261 { |
7363 | 7262 if (xproperties.xlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7263 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7264 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
|
7265 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7266 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
|
7267 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7268 xproperties.xscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7269 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7270 update_type = 'x'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7271 } |
7222 | 7272 } |
7273 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
|
7274 || axis_type == "ylimmode" || axis_type == "yliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7275 || axis_type == "ylim") |
7222 | 7276 { |
7363 | 7277 if (xproperties.ylimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7278 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7279 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
|
7280 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7281 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
|
7282 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7283 xproperties.yscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7284 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7285 update_type = 'y'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7286 } |
7222 | 7287 } |
7288 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
|
7289 || axis_type == "zlimmode" || axis_type == "zliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7290 || axis_type == "zlim") |
7222 | 7291 { |
7363 | 7292 if (xproperties.zlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7293 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7294 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
|
7295 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7296 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
|
7297 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7298 xproperties.zscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7299 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7300 update_type = 'z'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7301 } |
7222 | 7302 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7303 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
|
7304 || axis_type == "cdatamapping" || axis_type == "climinclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7305 || axis_type == "clim") |
7222 | 7306 { |
7363 | 7307 if (xproperties.climmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7308 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7309 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
|
7310 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7311 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7312 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7313 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7314 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7315 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7316 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7317 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7318 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7319 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
7320 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7321 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7322 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7323 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7324 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7325 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7326 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7327 update_type = 'c'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7328 } |
7222 | 7329 |
7330 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7331 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
|
7332 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7333 || 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
|
7334 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7335 if (xproperties.alimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7336 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7337 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
|
7338 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7339 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7340 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7341 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7342 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7343 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7344 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7345 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7346 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7347 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7348 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7349 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7350 limits(1) = max_val; |
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 = 'a'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7353 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7354 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7355 } |
7222 | 7356 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
7357 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
7358 frame.protect_var (updating_axis_limits); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
7359 |
18892
868dcab453bd
Distinguish axes when checking for recursion in axes limits updates (bug #40005).
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18877
diff
changeset
|
7360 updating_axis_limits.insert (get_handle ().value ()); |
7222 | 7361 |
7362 switch (update_type) | |
7363 { | |
7364 case 'x': | |
7365 xproperties.set_xlim (limits); | |
7366 xproperties.set_xlimmode ("auto"); | |
7446 | 7367 xproperties.update_xlim (); |
7222 | 7368 break; |
7369 | |
7370 case 'y': | |
7371 xproperties.set_ylim (limits); | |
7372 xproperties.set_ylimmode ("auto"); | |
7446 | 7373 xproperties.update_ylim (); |
7222 | 7374 break; |
7375 | |
7376 case 'z': | |
7377 xproperties.set_zlim (limits); | |
7378 xproperties.set_zlimmode ("auto"); | |
7446 | 7379 xproperties.update_zlim (); |
7222 | 7380 break; |
7381 | |
7382 case 'c': | |
7383 xproperties.set_clim (limits); | |
7384 xproperties.set_climmode ("auto"); | |
7385 break; | |
7386 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7387 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
|
7388 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
|
7389 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
|
7390 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7391 |
7222 | 7392 default: |
7393 break; | |
7394 } | |
7395 | |
7427 | 7396 xproperties.update_transform (); |
19153
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
7397 |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
7398 // Disable rotate3d and select pan for 2D plots |
52e01aa1fe8b
Overhaul FLTK pan, rotate, zoom
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19142
diff
changeset
|
7399 xproperties.set_rotate3d (xproperties.get_rotate3d ()); |
7214 | 7400 } |
7401 | |
9455 | 7402 inline |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
7403 double force_in_range (double x, double lower, double upper) |
9455 | 7404 { |
7405 if (x < lower) | |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
7406 return lower; |
9455 | 7407 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
|
7408 return upper; |
9455 | 7409 else |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
7410 return x; |
9455 | 7411 } |
7412 | |
14311
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7413 static Matrix |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7414 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
|
7415 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7416 Matrix new_lims = lims; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7417 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7418 double lo = lims(0); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7419 double hi = lims(1); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7420 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7421 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
|
7422 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7423 if (is_logscale) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7424 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7425 if (is_negative) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7426 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7427 double tmp = hi; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7428 hi = std::log10 (-lo); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7429 lo = std::log10 (-tmp); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7430 val = std::log10 (-val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7431 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7432 else |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7433 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7434 hi = std::log10 (hi); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7435 lo = std::log10 (lo); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7436 val = std::log10 (val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7437 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7438 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7439 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7440 // Perform the zooming |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7441 lo = val + factor * (lo - val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7442 hi = val + factor * (hi - val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7443 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7444 if (is_logscale) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7445 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7446 if (is_negative) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7447 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7448 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
|
7449 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
|
7450 lo = tmp; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7451 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7452 else |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7453 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7454 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
|
7455 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
|
7456 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7457 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7458 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7459 new_lims(0) = lo; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7460 new_lims(1) = hi; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7461 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7462 return new_lims; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7463 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
7464 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7465 void |
9455 | 7466 axes::properties::zoom_about_point (double x, double y, double factor, |
7467 bool push_to_zoom_stack) | |
7468 { | |
7469 // FIXME: Do we need error checking here? | |
7470 Matrix xlims = get_xlim ().matrix_value (); | |
7471 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7472 |
9455 | 7473 // Get children axes limits |
7474 Matrix kids = get_children (); | |
7475 double minx = octave_Inf; | |
7476 double maxx = -octave_Inf; | |
7477 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
|
7478 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7479 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x'); |
9455 | 7480 |
7481 double miny = octave_Inf; | |
7482 double maxy = -octave_Inf; | |
7483 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
|
7484 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7485 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
|
7486 |
14324
5a2b012b10c7
allow zooming for logscale plots
John W. Eaton <jwe@octave.org>
parents:
14323
diff
changeset
|
7487 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
|
7488 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
|
7489 |
9455 | 7490 zoom (xlims, ylims, push_to_zoom_stack); |
7491 } | |
7492 | |
7493 void | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
7494 axes::properties::zoom (const Matrix& xl, const Matrix& yl, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
7495 bool push_to_zoom_stack) |
9455 | 7496 { |
7497 if (push_to_zoom_stack) | |
7498 { | |
7499 zoom_stack.push_front (xlimmode.get ()); | |
7500 zoom_stack.push_front (xlim.get ()); | |
7501 zoom_stack.push_front (ylimmode.get ()); | |
7502 zoom_stack.push_front (ylim.get ()); | |
7503 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7504 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7505 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7506 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7507 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7508 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7509 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7510 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7511 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7512 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7513 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7514 |
14314
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7515 static Matrix |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7516 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
|
7517 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7518 Matrix new_lims = lims; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7519 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7520 double lo = lims(0); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7521 double hi = lims(1); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7522 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7523 bool is_negative = lo < 0 && hi < 0; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7524 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7525 double delta; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7526 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7527 if (is_logscale) |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7528 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7529 if (is_negative) |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7530 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7531 double tmp = hi; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7532 hi = std::log10 (-lo); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7533 lo = std::log10 (-tmp); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7534 x0 = -x0; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7535 x1 = -x1; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7536 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7537 else |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7538 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7539 hi = std::log10 (hi); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7540 lo = std::log10 (lo); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7541 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7542 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7543 delta = std::log10 (x0) - std::log10 (x1); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7544 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7545 else |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7546 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7547 delta = x0 - x1; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7548 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7549 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7550 // Perform the translation |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7551 lo += delta; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7552 hi += delta; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7553 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7554 if (is_logscale) |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7555 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7556 if (is_negative) |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7557 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7558 double tmp = -std::pow (10.0, hi); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7559 hi = -std::pow (10.0, lo); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7560 lo = tmp; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7561 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7562 else |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7563 { |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7564 lo = std::pow (10.0, lo); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7565 hi = std::pow (10.0, hi); |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7566 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7567 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7568 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7569 new_lims(0) = lo; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7570 new_lims(1) = hi; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7571 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7572 return new_lims; |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7573 } |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7574 |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7575 void |
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7576 axes::properties::translate_view (double x0, double x1, double y0, double y1) |
9455 | 7577 { |
7578 // FIXME: Do we need error checking here? | |
7579 Matrix xlims = get_xlim ().matrix_value (); | |
7580 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7581 |
9455 | 7582 // Get children axes limits |
7583 Matrix kids = get_children (); | |
7584 double minx = octave_Inf; | |
7585 double maxx = -octave_Inf; | |
7586 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
|
7587 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7588 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
|
7589 |
9455 | 7590 double miny = octave_Inf; |
7591 double maxy = -octave_Inf; | |
7592 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
|
7593 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7594 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
|
7595 |
14314
17de694961f5
make panning work for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14313
diff
changeset
|
7596 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
|
7597 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
|
7598 |
9455 | 7599 zoom (xlims, ylims, false); |
7600 } | |
7601 | |
7602 void | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7603 axes::properties::rotate_view (double delta_el, double delta_az) |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7604 { |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7605 Matrix v = get_view ().matrix_value (); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7606 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
7607 v(1) += delta_el; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
7608 |
15017
dd4ad69e4ab9
maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents:
14861
diff
changeset
|
7609 if (v(1) > 90) |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
7610 v(1) = 90; |
15017
dd4ad69e4ab9
maint: Fix a few Octave coding convention violations.
Rik <rik@octave.org>
parents:
14861
diff
changeset
|
7611 if (v(1) < -90) |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
7612 v(1) = -90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
7613 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
7614 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
|
7615 |
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
7616 set_view (v); |
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
|
7617 update_transform (); |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7618 } |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7619 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
7620 void |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7621 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7622 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7623 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7624 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7625 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7626 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7627 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7628 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7629 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7630 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7631 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7632 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7633 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7634 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7635 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7636 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7637 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7638 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7639 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7640 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7641 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7642 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7643 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7644 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7645 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7646 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7647 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
7648 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7649 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7650 axes::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7651 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
7652 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7653 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7654 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7655 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7656 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
|
7657 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7658 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
|
7659 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7660 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
|
7661 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
|
7662 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
|
7663 xinitialize (xproperties.get_zlabel ()); |
17098
786bcce466e9
Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents:
17081
diff
changeset
|
7664 |
786bcce466e9
Initialize the tightinset during initialization of axes.
Ben Abbott <bpabbott@mac.com>
parents:
17081
diff
changeset
|
7665 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
|
7666 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7667 |
7363 | 7668 // --------------------------------------------------------------------- |
7669 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7670 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7671 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
|
7672 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7673 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
|
7674 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7675 m(0) = xdata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7676 m(1) = xdata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7677 m(2) = xdata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7678 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
|
7679 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7680 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
|
7681 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7682 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7683 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7684 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
|
7685 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7686 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
|
7687 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7688 m(0) = ydata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7689 m(1) = ydata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
7690 m(2) = ydata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7691 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
|
7692 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
7693 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
|
7694 } |
6406 | 7695 |
7696 // --------------------------------------------------------------------- | |
7697 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7698 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7699 text::properties::get_data_position (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7700 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7701 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7702 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7703 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7704 pos = convert_text_position (pos, *this, get_units (), "data"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7705 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7706 return pos; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7707 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7708 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7709 Matrix |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7710 text::properties::get_extent_matrix (void) const |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7711 { |
14413
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7712 // 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
|
7713 return extent.get ().matrix_value (); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7714 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7715 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7716 octave_value |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7717 text::properties::get_extent (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7718 { |
14413
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7719 // 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
|
7720 // (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
|
7721 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
|
7722 Matrix pos = get_position ().matrix_value (); |
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7723 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
|
7724 |
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7725 m(0) += p(0); |
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7726 m(1) += p(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7727 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7728 return convert_text_position (m, *this, "pixels", get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7729 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7730 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7731 void |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7732 text::properties::update_font (void) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7733 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7734 #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
|
7735 #ifdef HAVE_FONTCONFIG |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7736 renderer.set_font (get ("fontname").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7737 get ("fontweight").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7738 get ("fontangle").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7739 get ("fontsize").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
|
7740 #endif |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7741 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
|
7742 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7743 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7744 |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7745 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7746 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
|
7747 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
7748 #ifdef HAVE_FREETYPE |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7749 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
7750 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
|
7751 int valign = 0; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7752 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7753 if (horizontalalignment_is ("center")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7754 halign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7755 else if (horizontalalignment_is ("right")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7756 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7757 |
16206
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16204
diff
changeset
|
7758 if (verticalalignment_is ("middle")) |
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16204
diff
changeset
|
7759 valign = 1; |
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16204
diff
changeset
|
7760 else if (verticalalignment_is ("top")) |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7761 valign = 2; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7762 else if (verticalalignment_is ("baseline")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7763 valign = 3; |
16206
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16204
diff
changeset
|
7764 else if (verticalalignment_is ("cap")) |
9ba5c5ed3aeb
Add new verticalalignment option 'cap' for OpenGL plotting.
Rik <rik@octave.org>
parents:
16204
diff
changeset
|
7765 valign = 4; |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7766 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7767 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
|
7768 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
7769 // 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
|
7770 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
7771 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
|
7772 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
7773 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
|
7774 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
7775 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
|
7776 halign, valign, get_rotation (), |
27fc61cfbc6e
Use interpreter property when rendering text objects (bug #39830).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17286
diff
changeset
|
7777 get_interpreter ()); |
14413
4f160344236a
2011-04-26 Daniel Wagenaar <daw@caltech.edu>
Ben Abbott <bpabbott@mac.com>
parents:
14395
diff
changeset
|
7778 /* 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
|
7779 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
|
7780 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
|
7781 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
|
7782 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
|
7783 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7784 #endif |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
7785 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
7786 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") || |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
7787 autopos_tag_is ("zlabel") || autopos_tag_is ("title")) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
7788 update_autopos ("sync"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7789 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7790 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7791 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7792 text::properties::request_autopos (void) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7793 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7794 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") || |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7795 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
|
7796 update_autopos (get_autopos_tag ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7797 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7798 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
7799 void |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7800 text::properties::update_units (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7801 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7802 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7803 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7804 set_xliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7805 set_yliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7806 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7807 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7808 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7809 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7810 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7811 pos = convert_text_position (pos, *this, cached_units, get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7812 // FIXME: if the current axes view is 2D, then one should |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7813 // probably drop the z-component of "pos" and leave "zliminclude" |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7814 // to "off". |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7815 set_position (pos); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7816 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7817 if (units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7818 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7819 set_xliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7820 set_yliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7821 // FIXME: see above |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7822 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7823 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7824 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7825 cached_units = get_units (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
7826 } |
6406 | 7827 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7828 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7829 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
|
7830 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7831 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7832 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
|
7833 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7834 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
|
7835 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7836 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
|
7837 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
|
7838 |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
7839 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
|
7840 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7841 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7842 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7843 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7844 |
6406 | 7845 // --------------------------------------------------------------------- |
7846 | |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
7847 octave_value |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
7848 image::properties::get_color_data (void) const |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
7849 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
7850 return convert_cdata (*this, get_cdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7851 cdatamapping_is ("scaled"), 3); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
7852 } |
6406 | 7853 |
7854 // --------------------------------------------------------------------- | |
7855 | |
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
|
7856 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
|
7857 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
|
7858 { |
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
|
7859 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
|
7860 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
|
7861 return Matrix (); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
7862 else |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
7863 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
|
7864 } |
6807 | 7865 |
19091
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7866 static bool updating_patch_data = false; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7867 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7868 void |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7869 patch::properties::update_fvc (void) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7870 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7871 if (updating_patch_data) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7872 return; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7873 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7874 Matrix xd = get_xdata ().matrix_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7875 Matrix yd = get_ydata ().matrix_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7876 Matrix zd = get_zdata ().matrix_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7877 NDArray cd = get_cdata ().array_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7878 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7879 bad_data_msg = std::string (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7880 if (xd.dims () != yd.dims () || |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7881 (xd.dims () != zd.dims () && ! zd.is_empty ())) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7882 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7883 bad_data_msg = "x/y/zdata should have the same dimensions"; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7884 return; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7885 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7886 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7887 // Faces and Vertices |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7888 dim_vector dv; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7889 bool is3D = false; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7890 octave_idx_type nr = xd.rows (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7891 octave_idx_type nc = xd.columns (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7892 if (nr == 1 && nc > 1) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7893 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7894 nr = nc; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7895 nc = 1; |
19141
5bfedd39cc77
Fix indexing in patch if x/y/zdata are row vectors (bug #42822)
Andreas Weber <andy.weber.aw@gmail.com>
parents:
19095
diff
changeset
|
7896 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:
19095
diff
changeset
|
7897 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:
19095
diff
changeset
|
7898 zd = zd.as_column (); |
19091
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7899 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7900 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7901 dv(0) = nr * nc; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7902 if (zd.is_empty ()) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7903 dv(1) = 2; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7904 else |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7905 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7906 dv(1) = 3; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7907 is3D = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7908 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7909 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7910 Matrix vert (dv); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7911 Matrix idx (nc, nr); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7912 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7913 octave_idx_type kk = 0; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7914 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:
19082
diff
changeset
|
7915 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7916 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:
19082
diff
changeset
|
7917 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7918 vert(kk,0) = xd(ii,jj); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7919 vert(kk,1) = yd(ii,jj); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7920 if (is3D) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7921 vert(kk,2) = zd(ii,jj); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7922 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7923 idx(jj,ii) = static_cast<double> (kk+1); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7924 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7925 kk++; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7926 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7927 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7928 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7929 // facevertexcdata |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7930 Matrix fvc; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7931 if (cd.ndims () == 3) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7932 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7933 dv(0) = cd.rows () * cd.columns (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7934 dv(1) = cd.dims ()(2); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7935 fvc = cd.reshape (dv); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7936 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7937 else |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7938 fvc = cd.as_column (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7939 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7940 // FIXME: shouldn't we update facevertexalphadata here ? |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7941 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7942 unwind_protect frame; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7943 frame.protect_var (updating_patch_data); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7944 updating_patch_data = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7945 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7946 faces.set (idx); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7947 vertices.set (vert); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7948 facevertexcdata.set (fvc); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7949 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7950 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7951 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7952 void |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7953 patch::properties::update_data (void) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7954 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7955 if (updating_patch_data) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7956 return; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7957 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7958 Matrix idx = get_faces ().matrix_value ().transpose (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7959 Matrix vert = get_vertices ().matrix_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7960 NDArray fvc = get_facevertexcdata ().array_value (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7961 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7962 octave_idx_type nfaces = idx.columns (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7963 octave_idx_type nvert = vert.rows (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7964 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7965 // Check all vertices in faces are defined |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7966 bad_data_msg = std::string (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7967 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:
19082
diff
changeset
|
7968 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7969 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:
19082
diff
changeset
|
7970 return; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7971 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7972 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7973 // Replace NaNs |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7974 if (idx.any_element_is_inf_or_nan ()) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7975 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7976 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:
19082
diff
changeset
|
7977 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7978 double valid_vert = idx(0,jj); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7979 bool turn_valid = false; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7980 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:
19082
diff
changeset
|
7981 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7982 if (xisnan (idx(ii,jj)) || turn_valid) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7983 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7984 idx(ii,jj) = valid_vert; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7985 turn_valid = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7986 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7987 else |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7988 valid_vert = idx(ii,jj); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7989 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7990 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7991 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7992 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7993 // Build cdata |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7994 dim_vector dv = dim_vector::alloc (3); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7995 NDArray cd; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7996 bool pervertex = false; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7997 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7998 if (fvc.rows () == nfaces || fvc.rows () == 1) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
7999 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8000 dv(0) = 1; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8001 dv(1) = fvc.rows (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8002 dv(2) = fvc.columns (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8003 cd = fvc.reshape (dv); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8004 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8005 else |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8006 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8007 if (! fvc.is_empty ()) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8008 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8009 dv(0) = idx.rows (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8010 dv(1) = nfaces; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8011 dv(2) = fvc.columns (); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8012 cd.resize (dv); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8013 pervertex = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8014 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8015 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8016 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8017 // Build x,y,zdata and eventually per vertex cdata |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8018 Matrix xd (idx.dims ()); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8019 Matrix yd (idx.dims ()); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8020 Matrix zd; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8021 bool has_zd = false; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8022 if (vert.columns () > 2) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8023 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8024 zd = Matrix (idx.dims ()); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8025 has_zd = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8026 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8027 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8028 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8029 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:
19082
diff
changeset
|
8030 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8031 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:
19082
diff
changeset
|
8032 { |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8033 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:
19082
diff
changeset
|
8034 xd(ii,jj) = vert(row,0); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8035 yd(ii,jj) = vert(row,1); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8036 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8037 if (has_zd) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8038 zd(ii,jj) = vert(row,2); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8039 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8040 if (pervertex) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8041 for (int kk = 0; kk < fvc.columns (); kk++) |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8042 cd(ii,jj,kk) = fvc(row,kk); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8043 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8044 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8045 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8046 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8047 unwind_protect frame; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8048 frame.protect_var (updating_patch_data); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8049 updating_patch_data = true; |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8050 |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8051 set_xdata (xd); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8052 set_ydata (yd); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8053 set_zdata (zd); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8054 set_cdata (cd); |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8055 } |
df972b9d080a
Translate patch property listeners to C++ (bug #42159)
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
19082
diff
changeset
|
8056 |
6807 | 8057 // --------------------------------------------------------------------- |
8058 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8059 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8060 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
|
8061 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8062 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
|
8063 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8064 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8065 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8066 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
|
8067 double x2, double y2, double z2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8068 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
|
8069 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8070 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
|
8071 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
|
8072 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
|
8073 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8074 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8075 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8076 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
|
8077 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8078 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8079 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8080 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
|
8081 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
|
8082 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
|
8083 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
8084 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
|
8085 int q = z.rows (); |
19142
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8086 |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8087 // 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:
19141
diff
changeset
|
8088 // 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:
19141
diff
changeset
|
8089 // 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:
19141
diff
changeset
|
8090 // 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:
19141
diff
changeset
|
8091 // 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:
19141
diff
changeset
|
8092 // normals until dimensions match. |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8093 if (x.columns () != p || y.rows () != q) |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8094 return; |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8095 |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8096 NDArray n (dim_vector (q, p, 3), 0.0); |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8097 |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8098 bool x_mat = (x.rows () == q); |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8099 bool y_mat = (y.columns () == p); |
c66029adf853
Fix out-of-bound indexing in update_normals (bug #42823).
Rik <rik@octave.org>
parents:
19141
diff
changeset
|
8100 |
18099
6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents:
17861
diff
changeset
|
8101 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
|
8102 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
|
8103 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
|
8104 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8105 for (int i = 0; i < p; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8106 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8107 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8108 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8109 i1 = i - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8110 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8111 i3 = i + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8112 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8113 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8114 for (int j = 0; j < q; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8115 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8116 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8117 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8118 j1 = j - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8119 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8120 j3 = j + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8121 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8122 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8123 double& nx = n(j, i, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8124 double& ny = n(j, i, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8125 double& nz = n(j, i, 2); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8126 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8127 if ((j > 0) && (i > 0)) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8128 // upper left quadrangle |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8129 cross_product |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8130 (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
|
8131 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
|
8132 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8133 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8134 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
|
8135 // upper right quadrangle |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8136 cross_product |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8137 (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
|
8138 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
|
8139 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8140 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8141 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
|
8142 // lower left quadrangle |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8143 cross_product |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8144 (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
|
8145 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
|
8146 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8147 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8148 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
|
8149 // lower right quadrangle |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8150 cross_product |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8151 (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
|
8152 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
|
8153 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
8154 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
8155 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
|
8156 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8157 nx /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8158 ny /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8159 nz /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8160 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8161 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8162 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8163 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
8164 } |
6406 | 8165 |
8166 // --------------------------------------------------------------------- | |
8167 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8168 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8169 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
|
8170 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8171 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8172 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8173 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8174 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8175 obj.update_axis_limits ("xlim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8176 obj.update_axis_limits ("ylim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8177 obj.update_axis_limits ("zlim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8178 obj.update_axis_limits ("clim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8179 obj.update_axis_limits ("alim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8180 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8181 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8182 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8183 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8184 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
|
8185 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8186 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8187 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8188 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8189 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8190 obj.update_axis_limits ("xlim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8191 obj.update_axis_limits ("ylim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8192 obj.update_axis_limits ("zlim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8193 obj.update_axis_limits ("clim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8194 obj.update_axis_limits ("alim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8195 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8196 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8197 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8198 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
|
8199 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8200 void |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8201 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
|
8202 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
|
8203 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8204 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
|
8205 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8206 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8207 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
|
8208 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8209 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
|
8210 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
|
8211 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8212 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
|
8213 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8214 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8215 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8216 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8217 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
|
8218 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8219 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
|
8220 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8221 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
|
8222 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8223 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8224 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
|
8225 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8226 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
|
8227 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8228 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8229 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
|
8230 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8231 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
|
8232 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8233 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8234 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
|
8235 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8236 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
|
8237 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8238 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8239 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
|
8240 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8241 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
|
8242 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8243 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8244 |
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
|
8245 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
|
8246 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8247 val = limits(0); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
8248 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
|
8249 min_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8250 val = limits(1); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
8251 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
|
8252 max_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8253 val = limits(2); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
8254 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
|
8255 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8256 val = limits(3); |
16971
259c1f295a1e
Use xfinite to replace some (isinf || isnan) instances in C++ code.
Rik <rik@octave.org>
parents:
16892
diff
changeset
|
8257 if (xfinite (val)) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8258 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
|
8259 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8260 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8261 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
8262 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
|
8263 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
|
8264 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
|
8265 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8266 limits(3) = max_neg; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8267 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8268 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8269 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
|
8270 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8271 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8272 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
|
8273 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8274 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
|
8275 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8276 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
|
8277 || 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
|
8278 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8279 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
|
8280 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
|
8281 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8282 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
|
8283 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8284 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8285 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8286 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8287 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
|
8288 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8289 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8290 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8291 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
|
8292 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8293 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8294 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8295 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
|
8296 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8297 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8298 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8299 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
|
8300 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8301 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8302 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8303 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
|
8304 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8305 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8306 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8307 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8308 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8309 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8310 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
|
8311 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8312 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8313 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8314 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8315 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8316 { |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8317 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
|
8318 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8319 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8320 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8321 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8322 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8323 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8324 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8325 double max_neg = -octave_Inf; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8326 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8327 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8328 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
8329 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8330 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8331 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
|
8332 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8333 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8334 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
8335 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8336 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8337 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
|
8338 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8339 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8340 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
8341 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8342 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8343 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
|
8344 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8345 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8346 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
8347 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8348 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8349 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
|
8350 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8351 update_type = 'c'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8352 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
8353 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8354 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8355 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
|
8356 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8357 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8358 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8359 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8360 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8361 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
|
8362 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
8363 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
|
8364 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8365 Matrix limits (1, 4, 0.0); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8366 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8367 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8368 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8369 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
8370 limits(3) = max_neg; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8371 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8372 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8373 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8374 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8375 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8376 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8377 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8378 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8379 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8380 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8381 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8382 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8383 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8384 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8385 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8386 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8387 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8388 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8389 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8390 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8391 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8392 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8393 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8394 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8395 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8396 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8397 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8398 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8399 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8400 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8401 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8402 |
6406 | 8403 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
|
8404 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
|
8405 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8406 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
|
8407 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
8408 graphics_object parent_obj = |
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
8409 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
|
8410 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8411 parent_size = parent_bbox.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
|
8412 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8413 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
|
8414 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8415 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8416 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8417 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
|
8418 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8419 #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
|
8420 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8421 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
|
8422 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
|
8423 Matrix box; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8424 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8425 // 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
|
8426 // FIXME: support multiline text |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
8427 |
17269
5b088598df1d
Add simple TeX parser based on flex/bison.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
17260
diff
changeset
|
8428 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
|
8429 #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
|
8430 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
|
8431 get_fontweight (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8432 get_fontangle (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8433 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
|
8434 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8435 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
|
8436 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
|
8437 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8438 Matrix ext (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8439 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8440 // 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
|
8441 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8442 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
|
8443 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
|
8444 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
|
8445 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8446 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
|
8447 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8448 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8449 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8450 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8451 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8452 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
|
8453 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8454 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
|
8455 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
8456 graphics_object parent_obj = 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
|
8457 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8458 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
8459 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8460 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
|
8461 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
|
8462 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8463 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
|
8464 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8465 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8466 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8467 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
|
8468 { |
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
|
8469 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
|
8470 style = st; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8471 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8472 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
|
8473 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8474 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8475 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8476 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
|
8477 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
|
8478 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8479 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
|
8480 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
|
8481 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8482 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8483 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8484 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8485 |
17608
e7692efcbd0d
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17607
diff
changeset
|
8486 if (obj.valid_object ()) |
e7692efcbd0d
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17607
diff
changeset
|
8487 parent_size = |
e7692efcbd0d
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17607
diff
changeset
|
8488 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
e7692efcbd0d
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17607
diff
changeset
|
8489 else |
e7692efcbd0d
graphics.cc: don't ask for (orphan) dummy axes parent properties.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
17607
diff
changeset
|
8490 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
|
8491 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8492 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8493 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
|
8494 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8495 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8496 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8497 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
|
8498 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8499 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8500 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8501 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8502 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8503 uicontrol::properties::set_fontunits (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8504 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8505 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8506 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8507 caseless_str old_fontunits = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8508 if (fontunits.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8509 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8510 update_fontunits (old_fontunits); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8511 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8512 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8513 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8514 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8515 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8516 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8517 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
|
8518 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8519 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
|
8520 double parent_height = get_boundingbox (false).elem (3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8521 double fsz = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8522 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8523 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8524 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8525 fontsize.set (octave_value (fsz), true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8526 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8527 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8528 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8529 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
|
8530 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8531 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8532 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
|
8533 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8534 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
|
8535 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
|
8536 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8537 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8538 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8539 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8540 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8541 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8542 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8543 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
|
8544 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
|
8545 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8546 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
|
8547 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
|
8548 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8549 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8550 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8551 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8552 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8553 parent_size = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8554 obj.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
|
8555 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8556 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8557 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
|
8558 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8559 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8560 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8561 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
|
8562 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8563 if (internal) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8564 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8565 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
|
8566 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8567 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
|
8568 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8569 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
|
8570 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8571 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
|
8572 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
|
8573 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8574 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
|
8575 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
|
8576 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8577 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
|
8578 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
|
8579 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
|
8580 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
|
8581 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8582 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8583 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
|
8584 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8585 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8586 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8587 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
|
8588 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8589 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
|
8590 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8591 if (fontunits_is ("points")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8592 fs *= (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
|
8593 else if (fontunits_is ("inches")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8594 fs *= res; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8595 else if (fontunits_is ("centimeters")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8596 fs *= (res / 2.54); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8597 else if (fontunits_is ("normalized")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8598 fs *= outer_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8599 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8600 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8601 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
|
8602 || titleposition_is ("righttop")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8603 pos(1) += (fs / 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8604 pos(3) -= (fs / 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8605 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8606 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8607 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8608 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8609 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8610 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8611 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8612 uipanel::properties::set_units (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8613 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8614 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8615 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8616 caseless_str old_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
|
8617 if (units.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8618 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8619 update_units (old_units); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8620 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8621 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8622 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8623 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8624 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8625 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8626 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
|
8627 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8628 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
|
8629 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
8630 graphics_object parent_obj = 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
|
8631 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8632 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
8633 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8634 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
|
8635 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
|
8636 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8637 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8638 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8639 uipanel::properties::set_fontunits (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8640 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8641 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8642 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8643 caseless_str old_fontunits = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8644 if (fontunits.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8645 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8646 update_fontunits (old_fontunits); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8647 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8648 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8649 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8650 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8651 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8652 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8653 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
|
8654 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8655 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
|
8656 double parent_height = get_boundingbox (false).elem (3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8657 double fsz = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8658 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8659 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8660 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8661 set_fontsize (octave_value (fsz)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8662 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8663 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8664 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8665 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
|
8666 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8667 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8668 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
|
8669 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8670 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
|
8671 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
|
8672 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8673 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8674 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8675 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8676 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8677 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8678 octave_value |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8679 uitoolbar::get_default (const caseless_str& name) const |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8680 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8681 octave_value retval = default_properties.lookup (name); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8682 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8683 if (retval.is_undefined ()) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8684 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8685 graphics_handle parent = get_parent (); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8686 graphics_object parent_obj = gh_manager::get_object (parent); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8687 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8688 retval = parent_obj.get_default (name); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8689 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8690 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8691 return retval; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8692 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8693 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8694 void |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8695 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
|
8696 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8697 ::reset_default_properties (default_properties); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8698 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8699 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8700 // --------------------------------------------------------------------- |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8701 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8702 octave_value |
7189 | 8703 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 8704 { |
8705 graphics_handle parent = get_parent (); | |
8706 graphics_object parent_obj = gh_manager::get_object (parent); | |
8707 | |
8708 return parent_obj.get_default (type () + name); | |
8709 } | |
8710 | |
8711 octave_value | |
7189 | 8712 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 8713 { |
8714 graphics_object parent_obj = gh_manager::get_object (0); | |
8715 | |
8716 return parent_obj.get_factory_default (type () + name); | |
8717 } | |
8718 | |
7286 | 8719 // We use a random value for the handle to avoid issues with plots and |
8720 // scalar values for the first argument. | |
6406 | 8721 gh_manager::gh_manager (void) |
7286 | 8722 : handle_map (), handle_free_list (), |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8723 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
|
8724 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
|
8725 callback_objects (), event_processing (0) |
6406 | 8726 { |
8727 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
8728 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8729 // 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
|
8730 gtk_manager::default_toolkit (); |
6406 | 8731 } |
8732 | |
13992
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8733 void |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8734 gh_manager::create_instance (void) |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8735 { |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8736 instance = new gh_manager (); |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8737 |
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
|
8738 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
|
8739 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
|
8740 } |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
8741 |
6406 | 8742 graphics_handle |
8743 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
|
8744 const graphics_handle& p, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8745 bool integer_figure_handle, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8746 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
|
8747 bool do_notify_toolkit) |
6406 | 8748 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8749 graphics_handle h = get_handle (integer_figure_handle); |
6406 | 8750 |
8751 base_graphics_object *go = 0; | |
8752 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
8753 go = make_graphics_object_from_type (go_name, h, p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8754 |
6406 | 8755 if (go) |
7370 | 8756 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8757 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8758 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8759 handle_map[h] = obj; |
7370 | 8760 if (do_createfcn) |
8761 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
8762 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8763 // 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
|
8764 if (do_notify_toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8765 obj.initialize (); |
7370 | 8766 } |
6406 | 8767 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
8768 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
|
8769 go_name.c_str ()); |
6406 | 8770 |
8771 return h; | |
8772 } | |
8773 | |
8774 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
|
8775 gh_manager::do_make_figure_handle (double val, bool do_notify_toolkit) |
6406 | 8776 { |
8777 graphics_handle h = val; | |
8778 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
8779 base_graphics_object* go = new figure (h, 0); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8780 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8781 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
8782 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
8783 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8784 // 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
|
8785 if (do_notify_toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8786 obj.initialize (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8787 |
6406 | 8788 return h; |
8789 } | |
8790 | |
8791 void | |
8792 gh_manager::do_push_figure (const graphics_handle& h) | |
8793 { | |
8794 do_pop_figure (h); | |
8795 | |
8796 figure_list.push_front (h); | |
8797 } | |
8798 | |
8799 void | |
8800 gh_manager::do_pop_figure (const graphics_handle& h) | |
8801 { | |
8802 for (figure_list_iterator p = figure_list.begin (); | |
8803 p != figure_list.end (); | |
8804 p++) | |
8805 { | |
8806 if (*p == h) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8807 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8808 figure_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8809 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8810 } |
6406 | 8811 } |
8812 } | |
8813 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8814 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8815 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
|
8816 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8817 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8818 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
|
8819 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
|
8820 : 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
|
8821 callback (), callback_data (data) { } |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
8822 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8823 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
|
8824 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
|
8825 : 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
|
8826 callback (cb), callback_data (data) { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8827 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8828 void execute (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8829 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8830 if (callback.is_defined ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8831 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
|
8832 else |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8833 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
|
8834 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8835 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8836 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8837 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
|
8838 : base_graphics_event (), handle (), callback_name (), callback_data () |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8839 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8840 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8841 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8842 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8843 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
|
8844 octave_value callback; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8845 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8846 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8847 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8848 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8849 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
|
8850 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8851 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8852 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
|
8853 : 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
|
8854 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8855 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8856 void execute (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8857 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8858 function (function_data); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8859 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8860 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8861 private: |
12174 | 8862 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8863 graphics_event::event_fcn function; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8864 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8865 void* function_data; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8866 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8867 // 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
|
8868 function_event (void); |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8869 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8870 // No copying! |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8871 |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
8872 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
|
8873 |
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
8874 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
|
8875 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8876 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8877 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8878 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
|
8879 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8880 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8881 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
|
8882 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
|
8883 : 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
|
8884 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
|
8885 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8886 void execute (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8887 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8888 gh_manager::auto_lock guard; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8889 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8890 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
|
8891 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8892 if (go) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8893 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8894 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
|
8895 |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8896 if (p.ok ()) |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8897 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
|
8898 } |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8899 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8900 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8901 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8902 set_event (void) |
12174 | 8903 : base_graphics_event (), handle (), property_name (), property_value () |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
8904 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8905 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8906 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8907 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8908 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8909 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
|
8910 bool notify_toolkit; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8911 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8912 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8913 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8914 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
|
8915 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8916 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8917 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8918 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8919 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8920 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
|
8921 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8922 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8923 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8924 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8925 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
|
8926 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
|
8927 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
|
8928 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
|
8929 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8930 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
|
8931 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8932 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
|
8933 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8934 return e; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8935 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8936 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8937 graphics_event |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8938 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
|
8939 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8940 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8941 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8942 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8943 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
|
8944 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8945 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8946 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8947 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8948 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8949 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
|
8950 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
|
8951 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
|
8952 bool notify_toolkit) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8953 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8954 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
8955 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8956 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
|
8957 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8958 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8959 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8960 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8961 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8962 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8963 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8964 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
|
8965 root_figure::properties& props = |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
8966 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
|
8967 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8968 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
|
8969 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8970 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8971 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8972 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8973 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8974 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8975 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8976 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8977 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8978 xset_gcbo (callback_objects.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8979 ? graphics_handle () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8980 : callback_objects.front ().get_handle ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8981 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8982 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8983 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8984 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
|
8985 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
|
8986 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8987 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
|
8988 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
|
8989 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8990 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8991 gh_manager::auto_lock guard; |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
8992 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8993 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
|
8994 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8995 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8996 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8997 void |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8998 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
|
8999 const octave_value& cb_arg, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9000 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9001 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9002 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
|
9003 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9004 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
|
9005 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
|
9006 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9007 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
|
9008 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
|
9009 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
|
9010 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9011 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
|
9012 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9013 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
|
9014 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
|
9015 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9016 if (true) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9017 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9018 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
|
9019 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9020 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
|
9021 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
|
9022 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9023 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9024 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
|
9025 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9026 // 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
|
9027 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9028 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
|
9029 |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9030 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
|
9031 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
|
9032 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
|
9033 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9034 int status; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9035 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
|
9036 |
13940
bf209050014f
Use nargout = 0 in graphics callbacks specified as string.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13935
diff
changeset
|
9037 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
|
9038 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9039 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
|
9040 && (cb.rows () == 1 || cb.columns () == 1) |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9041 && (cb.cell_value ()(0).is_function () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9042 || 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
|
9043 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9044 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
|
9045 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9046 fcn = c(0).function_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9047 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9048 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9049 for (int i = 1; i < c.length () ; i++) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9050 args(1+i) = c(i); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9051 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9052 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9053 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9054 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9055 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
|
9056 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
|
9057 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
|
9058 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9059 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9060 if (fcn && ! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9061 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
|
9062 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9063 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
|
9064 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9065 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9066 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9067 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
9068 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
|
9069 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9070 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9071 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9072 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
|
9073 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9074 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9075 void |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
9076 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
|
9077 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9078 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9079 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9080 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9081 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9082 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9083 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9084 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9085 if (callback_objects.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9086 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
|
9087 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9088 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9089 const graphics_object& current = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9090 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9091 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
|
9092 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
|
9093 data)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9094 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9095 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9096 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
|
9097 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9098 if (busy_action.compare ("queue")) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9099 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
|
9100 data)); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9101 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9102 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9103 caseless_str cname (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9104 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9105 if (cname.compare ("deletefcn") || cname.compare ("createfcn") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9106 || (go.isa ("figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9107 && (cname.compare ("closerequestfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9108 || cname.compare ("resizefcn")))) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9109 do_post_event ( |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9110 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
|
9111 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9112 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9113 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9114 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9115 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9116 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9117 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
9118 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
|
9119 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9120 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9121 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
9122 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
|
9123 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9124 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9125 void |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
9126 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
|
9127 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
|
9128 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9129 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
|
9130 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9131 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
|
9132 notify_toolkit)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9133 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9134 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9135 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9136 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
|
9137 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
9138 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
|
9139 bool old_Vdrawnow_requested = Vdrawnow_requested; |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9140 bool events_executed = false; |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9141 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9142 do |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9143 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9144 e = graphics_event (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9145 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9146 gh_manager::lock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9147 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9148 if (! event_queue.empty ()) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9149 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9150 if (callback_objects.empty () || force) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9151 { |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9152 e = event_queue.front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9153 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9154 event_queue.pop_front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9155 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9156 else |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9157 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9158 const graphics_object& go = callback_objects.front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9159 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9160 if (go.get_properties ().is_interruptible ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9161 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9162 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9163 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9164 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9165 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9166 } |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9167 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9168 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9169 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9170 |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9171 if (e.ok ()) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9172 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9173 e.execute (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9174 events_executed = true; |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9175 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9176 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9177 while (e.ok ()); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9178 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9179 gh_manager::lock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9180 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9181 if (event_queue.empty () && event_processing == 0) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9182 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
|
9183 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9184 gh_manager::unlock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9185 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9186 if (events_executed) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9187 flush_octave_stdout (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9188 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9189 if (Vdrawnow_requested && ! old_Vdrawnow_requested) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9190 { |
15423
53d073233fa4
call more built-in functions directly
John W. Eaton <jwe@octave.org>
parents:
15220
diff
changeset
|
9191 Fdrawnow (); |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9192 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
9193 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
|
9194 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9195 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9196 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9197 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9198 |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
9199 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9200 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
|
9201 { |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
9202 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
|
9203 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9204 if (enable) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9205 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9206 event_processing++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9207 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9208 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
|
9209 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9210 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9211 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9212 event_processing--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9213 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9214 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
|
9215 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
|
9216 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9217 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9218 |
6406 | 9219 property_list::plist_map_type |
9220 root_figure::init_factory_properties (void) | |
9221 { | |
9222 property_list::plist_map_type plist_map; | |
9223 | |
6844 | 9224 plist_map["figure"] = figure::properties::factory_defaults (); |
9225 plist_map["axes"] = axes::properties::factory_defaults (); | |
9226 plist_map["line"] = line::properties::factory_defaults (); | |
9227 plist_map["text"] = text::properties::factory_defaults (); | |
9228 plist_map["image"] = image::properties::factory_defaults (); | |
9229 plist_map["patch"] = patch::properties::factory_defaults (); | |
9230 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9231 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
|
9232 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
|
9233 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
|
9234 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
|
9235 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
|
9236 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
|
9237 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
|
9238 plist_map["uitoggletool"] = uitoggletool::properties::factory_defaults (); |
6406 | 9239 |
9240 return plist_map; | |
9241 } | |
9242 | |
9243 // --------------------------------------------------------------------- | |
9244 | |
9245 DEFUN (ishandle, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9246 "-*- texinfo -*-\n\ |
6678 | 9247 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 9248 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
|
9249 \n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
9250 @var{h} may also be a matrix of handles in which case a logical\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
9251 array is returned that is true where the elements of @var{h} are\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
9252 graphics handles and 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
|
9253 @seealso{isaxes, isfigure}\n\ |
6406 | 9254 @end deftypefn") |
9255 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9256 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9257 |
6406 | 9258 octave_value retval; |
9259 | |
9260 if (args.length () == 1) | |
9261 retval = is_handle (args(0)); | |
9262 else | |
9263 print_usage (); | |
9264 | |
9265 return retval; | |
9266 } | |
9267 | |
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
|
9268 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
|
9269 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
|
9270 { |
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
|
9271 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
|
9272 } |
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
|
9273 |
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
|
9274 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
|
9275 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
|
9276 { |
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
|
9277 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
|
9278 } |
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
|
9279 |
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
|
9280 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
|
9281 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
|
9282 { |
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
|
9283 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
|
9284 |
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
|
9285 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
|
9286 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
|
9287 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
|
9288 { |
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
|
9289 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
|
9290 |
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
|
9291 if (! error_state) |
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
|
9292 { |
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
|
9293 boolNDArray result (handles.dims ()); |
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
|
9294 |
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
|
9295 for (octave_idx_type i = 0; i < handles.numel (); i++) |
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
|
9296 result.xelem (i) = is_handle_visible (handles (i)); |
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
|
9297 |
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
|
9298 retval = result; |
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
|
9299 } |
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
|
9300 } |
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
|
9301 |
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
|
9302 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
|
9303 } |
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
|
9304 |
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
|
9305 DEFUN (__is_handle_visible__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9306 "-*- texinfo -*-\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
|
9307 @deftypefn {Built-in Function} __is_handle_visible__ (@var{h})\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
|
9308 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
|
9309 @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
|
9310 { |
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
|
9311 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
|
9312 |
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
|
9313 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
|
9314 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
|
9315 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
|
9316 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
|
9317 |
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
|
9318 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
|
9319 } |
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
|
9320 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9321 DEFUN (reset, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9322 "-*- texinfo -*-\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9323 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
9324 Remove any defaults set for the handle @var{h}. The default figure\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
9325 properties of @qcode{\"position\"}, @qcode{\"units\"},\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
9326 @qcode{\"windowstyle\"} and @qcode{\"paperunits\"} and the default axes\n\ |
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
9327 properties of @qcode{\"position\"} and @qcode{\"units\"} are not reset.\n\ |
17443
0aa77acf22f5
doc: Add seealso references between cla, clf, reset functions.
Rik <rik@octave.org>
parents:
17382
diff
changeset
|
9328 @seealso{cla, clf}\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9329 @end deftypefn") |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9330 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9331 int nargin = args.length (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9332 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9333 if (nargin != 1) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9334 print_usage (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9335 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9336 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9337 // get vector of graphics handles |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9338 ColumnVector hcv (args(0).vector_value ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9339 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9340 if (! error_state) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9341 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9342 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
9343 for (octave_idx_type n = 0; n < hcv.length (); n++) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9344 gh_manager::get_object (hcv(n)).reset_default_properties (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9345 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9346 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9347 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9348 return octave_value (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9349 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
9350 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9351 DEFUN (set, args, nargout, |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9352 "-*- texinfo -*-\n\ |
10840 | 9353 @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
|
9354 @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
|
9355 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\ |
18658
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9356 @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:
18567
diff
changeset
|
9357 @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
|
9358 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
|
9359 handles) @var{h}.\n\ |
18658
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9360 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
|
9361 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9362 @itemize\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9363 @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
|
9364 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9365 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
|
9366 @var{value} is a value of the appropriate type for the property.\n\ |
10840 | 9367 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9368 @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
|
9369 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
|
9370 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9371 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
|
9372 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
|
9373 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
|
9374 @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
|
9375 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
|
9376 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
|
9377 the first row of @var{values} and so on.\n\ |
10840 | 9378 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9379 @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
|
9380 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9381 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
|
9382 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
|
9383 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
|
9384 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
|
9385 @end itemize\n\ |
18658
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9386 \n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9387 @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:
18567
diff
changeset
|
9388 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:
18567
diff
changeset
|
9389 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:
18567
diff
changeset
|
9390 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:
18567
diff
changeset
|
9391 screen.\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9392 \n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9393 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:
18567
diff
changeset
|
9394 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:
18567
diff
changeset
|
9395 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:
18567
diff
changeset
|
9396 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:
18567
diff
changeset
|
9397 printed to the screen.\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9398 \n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9399 For example,\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9400 \n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9401 @example\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9402 @group\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9403 hf = figure ();\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9404 set (hf, \"paperorientation\")\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9405 @result{} paperorientation: [ landscape | @{portrait@} | rotated ]\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9406 @end group\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9407 @end example\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9408 \n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9409 @noindent\n\ |
3dac2a233386
doc: Add documentation about using set() to query graphics properties.
Rik <rik@octave.org>
parents:
18567
diff
changeset
|
9410 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:
18567
diff
changeset
|
9411 being @qcode{\"portrait\"}.\n\ |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16750
diff
changeset
|
9412 @seealso{get}\n\ |
6406 | 9413 @end deftypefn") |
9414 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9415 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9416 |
6406 | 9417 octave_value retval; |
9418 | |
9419 int nargin = args.length (); | |
9420 | |
9421 if (nargin > 0) | |
9422 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9423 // get vector of graphics handles |
6732 | 9424 ColumnVector hcv (args(0).vector_value ()); |
6406 | 9425 |
9426 if (! error_state) | |
6732 | 9427 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9428 bool request_drawnow = false; |
6733 | 9429 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9430 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
9431 for (octave_idx_type n = 0; n < hcv.length (); n++) |
6732 | 9432 { |
9433 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 9434 |
6732 | 9435 if (obj) |
9436 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9437 if (nargin == 3 && args(1).is_cellstr () |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9438 && args(2).is_cell ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9439 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9440 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
|
9441 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9442 obj.set (args(1).cellstr_value (), |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9443 args(2).cell_value (), 0); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9444 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9445 else if (hcv.length () == args(2).cell_value ().rows ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9446 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9447 obj.set (args(1).cellstr_value (), |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9448 args(2).cell_value (), n); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9449 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9450 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9451 { |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
9452 error ("set: number of graphics handles must match number of value rows (%d != %d)", |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9453 hcv.length (), 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
|
9454 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9455 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9456 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9457 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9458 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
|
9459 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9460 obj.set (args(1).map_value ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9461 } |
18117
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9462 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
|
9463 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9464 std::string property = args(1).string_value (); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9465 |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9466 octave_map pmap = obj.values_as_struct (); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9467 |
18673
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
9468 if (obj.has_readonly_property (property)) |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
9469 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:
18658
diff
changeset
|
9470 retval = Matrix (); |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
9471 else |
5264b0ec9f97
Make set() omit read-only properties when called with 1 or 2 arguments (bug #41629).
pantxo <pantxo.diribarne@gmail.com>
parents:
18658
diff
changeset
|
9472 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:
18658
diff
changeset
|
9473 <<" 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:
18658
diff
changeset
|
9474 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
|
9475 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9476 if (nargout != 0) |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9477 retval = pmap.getfield (property)(0); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9478 else |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9479 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9480 std::string s = obj.value_as_string (property); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9481 if (! error_state) |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9482 octave_stdout << s; |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9483 } |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9484 } |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9485 else |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9486 { |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9487 error ("set: unknown property"); |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9488 break; |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9489 } |
ca84d3c9dc24
set: allow retrieving allowed values for individual properties
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
18111
diff
changeset
|
9490 } |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9491 else if (nargin == 1) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9492 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9493 if (nargout != 0) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9494 retval = obj.values_as_struct (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9495 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9496 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9497 std::string s = obj.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9498 if (! error_state) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9499 octave_stdout << s; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9500 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
9501 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9502 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9503 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9504 obj.set (args.splice (0, 1)); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9505 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9506 } |
6732 | 9507 } |
9508 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9509 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9510 error ("set: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9511 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9512 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9513 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9514 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9515 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9516 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
9517 request_drawnow = true; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9518 } |
6733 | 9519 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9520 if (! error_state && request_drawnow) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9521 Vdrawnow_requested = true; |
6732 | 9522 } |
6406 | 9523 else |
6732 | 9524 error ("set: expecting graphics handle as first argument"); |
6406 | 9525 } |
9526 else | |
9527 print_usage (); | |
9528 | |
9529 return retval; | |
9530 } | |
9531 | |
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
|
9532 static std::string |
18118
ec9b35e60f95
style fixes in graphics.in.h and graphics.cc
John W. Eaton <jwe@octave.org>
parents:
18117
diff
changeset
|
9533 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
|
9534 { |
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
|
9535 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
|
9536 |
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
|
9537 graphics_object obj = gh_manager::get_object (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
|
9538 |
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
|
9539 if (obj) |
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
|
9540 retval = obj.type (); |
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
|
9541 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
|
9542 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
|
9543 |
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
|
9544 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
|
9545 } |
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
|
9546 |
6406 | 9547 DEFUN (get, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9548 "-*- texinfo -*-\n\ |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16750
diff
changeset
|
9549 @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
|
9550 @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
|
9551 Return the value of the named property @var{p} from the graphics handle\n\ |
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16750
diff
changeset
|
9552 @var{h}. If @var{p} is omitted, return the complete property list for\n\ |
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16750
diff
changeset
|
9553 @var{h}. If @var{h} is a vector, return a cell array including the property\n\ |
6732 | 9554 values or lists respectively.\n\ |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
16750
diff
changeset
|
9555 @seealso{set}\n\ |
6406 | 9556 @end deftypefn") |
9557 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9558 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9559 |
6406 | 9560 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
|
9561 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9562 Cell vals; |
6406 | 9563 |
9564 int nargin = args.length (); | |
9565 | |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9566 bool use_cell_format = false; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9567 |
6406 | 9568 if (nargin == 1 || nargin == 2) |
9569 { | |
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
|
9570 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
|
9571 { |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
9572 retval = Matrix (); |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
9573 return retval; |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
9574 } |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
9575 |
6732 | 9576 ColumnVector hcv (args(0).vector_value ()); |
6406 | 9577 |
9578 if (! error_state) | |
6732 | 9579 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9580 octave_idx_type len = hcv.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9581 |
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
|
9582 if (nargin == 1 && len > 1) |
6732 | 9583 { |
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
|
9584 std::string t0 = get_graphics_object_type (hcv(0)); |
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
|
9585 |
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
|
9586 if (! error_state) |
6732 | 9587 { |
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
|
9588 for (octave_idx_type n = 1; n < len; n++) |
6732 | 9589 { |
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
|
9590 std::string t = get_graphics_object_type (hcv(n)); |
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
|
9591 |
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
|
9592 if (error_state) |
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
|
9593 break; |
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
|
9594 |
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
|
9595 if (t != t0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9596 { |
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
|
9597 error ("get: vector of handles must all have same type"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9598 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9599 } |
6732 | 9600 } |
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
|
9601 |
6732 | 9602 } |
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
|
9603 } |
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
|
9604 |
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
|
9605 if (! error_state) |
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
|
9606 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9607 if (nargin > 1 && args(1).is_cellstr ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9608 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9609 Array<std::string> plist = args(1).cellstr_value (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9610 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9611 if (! error_state) |
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
|
9612 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9613 octave_idx_type plen = plist.numel (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9614 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9615 use_cell_format = true; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9616 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9617 vals.resize (dim_vector (len, plen)); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9618 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9619 for (octave_idx_type n = 0; ! error_state && n < len; n++) |
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
|
9620 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9621 graphics_object obj = gh_manager::get_object (hcv(n)); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9622 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9623 if (obj) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9624 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9625 for (octave_idx_type m = 0; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9626 ! error_state && m < plen; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9627 m++) |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9628 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9629 caseless_str property = plist(m); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9630 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9631 vals(n, m) = obj.get (property); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9632 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9633 } |
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
|
9634 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
|
9635 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9636 error ("get: invalid handle (= %g)", hcv(n)); |
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
|
9637 break; |
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
|
9638 } |
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
|
9639 } |
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
|
9640 } |
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
|
9641 else |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9642 error ("get: expecting property name or cell array of property names as second argument"); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9643 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9644 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9645 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9646 caseless_str property; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9647 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9648 if (nargin > 1) |
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
|
9649 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9650 property = args(1).string_value (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9651 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9652 if (error_state) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9653 error ("get: expecting property name or cell array of property names as second argument"); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9654 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9655 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9656 vals.resize (dim_vector (len, 1)); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9657 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9658 if (! error_state) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9659 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9660 for (octave_idx_type n = 0; ! error_state && n < len; n++) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9661 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9662 graphics_object obj = gh_manager::get_object (hcv(n)); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9663 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9664 if (obj) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9665 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9666 if (nargin == 1) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9667 vals(n) = obj.get (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9668 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9669 vals(n) = obj.get (property); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9670 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9671 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9672 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9673 error ("get: invalid handle (= %g)", hcv(n)); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9674 break; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9675 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9676 } |
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
|
9677 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9678 } |
6732 | 9679 } |
9680 } | |
6406 | 9681 else |
6732 | 9682 error ("get: expecting graphics handle as first argument"); |
6406 | 9683 } |
9684 else | |
9685 print_usage (); | |
9686 | |
6733 | 9687 if (! error_state) |
6732 | 9688 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9689 if (use_cell_format) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9690 retval = vals; |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
9691 else |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9692 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9693 octave_idx_type len = vals.numel (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9694 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9695 if (len == 0) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9696 retval = Matrix (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9697 else if (len == 1) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9698 retval = vals(0); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9699 else if (len > 1 && nargin == 1) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9700 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9701 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9702 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9703 for (octave_idx_type n = 0; n < len; n++) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9704 tmp[n] = vals(n).scalar_map_value (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9705 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9706 retval = octave_map::cat (0, len, tmp); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9707 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9708 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9709 retval = vals; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
9710 } |
6732 | 9711 } |
9712 | |
6406 | 9713 return retval; |
9714 } | |
9715 | |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
9716 /* |
14429
eff4a5933e28
Update %!tests in src/ directory with Octave coding conventions.
Rik <octave@nomad.inbox5.com>
parents:
14413
diff
changeset
|
9717 %!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
|
9718 */ |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
9719 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
9720 // 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
|
9721 // 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
|
9722 // 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
|
9723 |
7379 | 9724 DEFUN (__get__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9725 "-*- texinfo -*-\n\ |
7379 | 9726 @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
|
9727 Undocumented internal function.\n\ |
7379 | 9728 @end deftypefn") |
9729 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9730 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9731 |
7379 | 9732 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
|
9733 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9734 Cell vals; |
7379 | 9735 |
9736 int nargin = args.length (); | |
9737 | |
9738 if (nargin == 1) | |
9739 { | |
9740 ColumnVector hcv (args(0).vector_value ()); | |
9741 | |
9742 if (! error_state) | |
9743 { | |
9744 octave_idx_type len = hcv.length (); | |
9745 | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9746 vals.resize (dim_vector (len, 1)); |
7379 | 9747 |
9748 for (octave_idx_type n = 0; n < len; n++) | |
9749 { | |
9750 graphics_object obj = gh_manager::get_object (hcv(n)); | |
9751 | |
9752 if (obj) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9753 vals(n) = obj.get (true); |
7379 | 9754 else |
9755 { | |
9756 error ("get: invalid handle (= %g)", hcv(n)); | |
9757 break; | |
9758 } | |
9759 } | |
9760 } | |
9761 else | |
9762 error ("get: expecting graphics handle as first argument"); | |
9763 } | |
9764 else | |
9765 print_usage (); | |
9766 | |
9767 if (! error_state) | |
9768 { | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9769 octave_idx_type len = vals.numel (); |
7379 | 9770 |
9771 if (len > 1) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9772 retval = vals; |
7379 | 9773 else if (len == 1) |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
9774 retval = vals(0); |
7379 | 9775 } |
9776 | |
9777 return retval; | |
9778 } | |
9779 | |
6406 | 9780 static octave_value |
9781 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
|
9782 bool integer_figure_handle, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9783 const octave_value_list& args) |
6406 | 9784 { |
9785 octave_value retval; | |
9786 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9787 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9788 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9789 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9790 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9791 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9792 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9793 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9794 if (xargs(i).is_string () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9795 && p.compare (xargs(i).string_value ())) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9796 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9797 if (i < (xargs.length () - 1)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9798 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9799 val = xargs(i+1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9800 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9801 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9802 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9803 xargs = xargs.splice (i, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9804 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9805 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9806 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9807 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9808 error ("__go_%s__: missing value for parent property", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9809 go_name.c_str ()); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9810 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9811 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9812 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
9813 val = args(0).double_value (); |
6406 | 9814 |
9815 if (! error_state) | |
9816 { | |
9817 graphics_handle parent = gh_manager::lookup (val); | |
9818 | |
7056 | 9819 if (parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9820 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9821 graphics_handle h |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9822 = 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
|
9823 integer_figure_handle, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9824 false, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9825 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9826 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9827 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9828 adopt (parent, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9829 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9830 xset (h, xargs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9831 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
|
9832 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9833 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9834 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9835 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9836 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9837 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9838 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9839 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9840 error ("__go%s__: unable to create graphics handle", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9841 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9842 } |
6406 | 9843 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9844 error ("__go_%s__: invalid parent", go_name.c_str ()); |
6406 | 9845 } |
9846 else | |
9847 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
9848 | |
9849 return retval; | |
9850 } | |
9851 | |
9852 DEFUN (__go_figure__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9853 "-*- texinfo -*-\n\ |
6406 | 9854 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ |
6945 | 9855 Undocumented internal function.\n\ |
6406 | 9856 @end deftypefn") |
9857 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9858 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9859 |
6406 | 9860 octave_value retval; |
9861 | |
9862 if (args.length () > 0) | |
9863 { | |
9864 double val = args(0).double_value (); | |
9865 | |
9866 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9867 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9868 if (is_figure (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9869 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9870 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9871 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9872 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9873 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9874 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9875 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9876 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9877 { |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9878 bool int_fig_handle = true; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9879 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9880 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
|
9881 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9882 graphics_handle h = octave_NaN; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9883 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9884 if (xisnan (val)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9885 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9886 caseless_str p ("integerhandle"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9887 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9888 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
|
9889 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9890 if (xargs(i).is_string () |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9891 && p.compare (xargs(i).string_value ())) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9892 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9893 if (i < (xargs.length () - 1)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9894 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9895 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
|
9896 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9897 if (! error_state) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9898 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9899 caseless_str on ("on"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9900 int_fig_handle = on.compare (pval); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9901 xargs = xargs.splice (i, 2); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9902 break; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9903 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9904 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9905 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9906 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9907 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9908 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
|
9909 int_fig_handle, |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9910 false, false); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9911 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9912 if (! int_fig_handle) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9913 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9914 // We need to intiailize the integerhandle |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9915 // property without calling the set_integerhandle |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9916 // method, because doing that will generate a new |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9917 // handle value... |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9918 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9919 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
|
9920 go.get_properties ().init_integerhandle ("off"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9921 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9922 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9923 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
|
9924 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
|
9925 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9926 if (! error_state && h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9927 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9928 adopt (0, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9929 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9930 gh_manager::push_figure (h); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9931 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
9932 xset (h, xargs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9933 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
|
9934 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9935 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9936 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9937 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9938 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9939 error ("__go_figure__: failed to create figure handle"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9940 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9941 } |
6406 | 9942 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9943 error ("__go_figure__: expecting figure number to be double value"); |
6406 | 9944 } |
9945 else | |
9946 print_usage (); | |
9947 | |
9948 return retval; | |
9949 } | |
9950 | |
9951 #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
|
9952 gh_manager::auto_lock guard; \ |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9953 \ |
6406 | 9954 octave_value retval; \ |
9955 \ | |
9956 if (args.length () > 0) \ | |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9957 retval = make_graphics_object (#TYPE, false, args); \ |
6406 | 9958 else \ |
9959 print_usage (); \ | |
9960 \ | |
9961 return retval | |
9962 | |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9963 int |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9964 calc_dimensions (const graphics_object& go) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9965 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9966 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9967 int nd = 2; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9968 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9969 if (go.isa ("surface")) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9970 nd = 3; |
17564
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9971 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
|
9972 && ! go.get ("zdata").is_empty ()) |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9973 nd = 3; |
17564
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9974 else |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9975 { |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9976 Matrix kids = go.get_properties ().get_children (); |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9977 |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9978 for (octave_idx_type i = 0; i < kids.length (); i++) |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9979 { |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9980 graphics_handle hnd = gh_manager::lookup (kids(i)); |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9981 |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9982 if (hnd.ok ()) |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9983 { |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9984 const graphics_object& kid = gh_manager::get_object (hnd); |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9985 |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9986 if (kid.valid_object ()) |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9987 nd = calc_dimensions (kid); |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9988 |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9989 if (nd == 3) |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9990 break; |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
9991 } |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9992 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9993 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9994 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9995 return nd; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9996 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9997 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
9998 DEFUN (__calc_dimensions__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
9999 "-*- texinfo -*-\n\ |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10000 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
10001 Internal function. Determine the number of dimensions in a graphics\n\ |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10002 object, whether 2 or 3.\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10003 @end deftypefn") |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10004 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10005 gh_manager::auto_lock guard; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10006 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10007 octave_value retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10008 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10009 int nargin = args.length (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10010 |
18961
5e99fd6ea758
graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17861
diff
changeset
|
10011 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
|
10012 { |
5e99fd6ea758
graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17861
diff
changeset
|
10013 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
|
10014 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
|
10015 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
|
10016 else |
5e99fd6ea758
graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17861
diff
changeset
|
10017 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
|
10018 } |
5e99fd6ea758
graphics.cc: fix segfault in __calc_dimensions__ when args is empty
Andreas Weber <andy.weber.aw@gmail.com>
parents:
17861
diff
changeset
|
10019 else |
17564
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
10020 print_usage (); |
234731d524c2
axis.m: Fix 'axis tight' with pcolor plots.
Rik <rik@octave.org>
parents:
17544
diff
changeset
|
10021 |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10022 return retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10023 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
10024 |
6406 | 10025 DEFUN (__go_axes__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10026 "-*- texinfo -*-\n\ |
6406 | 10027 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ |
6945 | 10028 Undocumented internal function.\n\ |
6406 | 10029 @end deftypefn") |
10030 { | |
10031 GO_BODY (axes); | |
10032 } | |
10033 | |
10034 DEFUN (__go_line__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10035 "-*- texinfo -*-\n\ |
6406 | 10036 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ |
6945 | 10037 Undocumented internal function.\n\ |
6406 | 10038 @end deftypefn") |
10039 { | |
10040 GO_BODY (line); | |
10041 } | |
10042 | |
10043 DEFUN (__go_text__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10044 "-*- texinfo -*-\n\ |
6406 | 10045 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ |
6945 | 10046 Undocumented internal function.\n\ |
6406 | 10047 @end deftypefn") |
10048 { | |
10049 GO_BODY (text); | |
10050 } | |
10051 | |
10052 DEFUN (__go_image__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10053 "-*- texinfo -*-\n\ |
6406 | 10054 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ |
6945 | 10055 Undocumented internal function.\n\ |
6406 | 10056 @end deftypefn") |
10057 { | |
10058 GO_BODY (image); | |
10059 } | |
10060 | |
10061 DEFUN (__go_surface__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10062 "-*- texinfo -*-\n\ |
6406 | 10063 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ |
6945 | 10064 Undocumented internal function.\n\ |
6406 | 10065 @end deftypefn") |
10066 { | |
10067 GO_BODY (surface); | |
10068 } | |
10069 | |
6807 | 10070 DEFUN (__go_patch__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10071 "-*- texinfo -*-\n\ |
6807 | 10072 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ |
6945 | 10073 Undocumented internal function.\n\ |
6807 | 10074 @end deftypefn") |
10075 { | |
10076 GO_BODY (patch); | |
10077 } | |
10078 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10079 DEFUN (__go_hggroup__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10080 "-*- texinfo -*-\n\ |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10081 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10082 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10083 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10084 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10085 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10086 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
10087 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10088 DEFUN (__go_uimenu__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10089 "-*- texinfo -*-\n\ |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10090 @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
|
10091 Undocumented internal function.\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10092 @end deftypefn") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10093 { |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10094 GO_BODY (uimenu); |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10095 } |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
10096 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10097 DEFUN (__go_uicontrol__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10098 "-*- 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
|
10099 @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
|
10100 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
|
10101 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10102 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10103 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
|
10104 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10105 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10106 DEFUN (__go_uipanel__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10107 "-*- 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
|
10108 @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
|
10109 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
|
10110 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10111 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10112 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
|
10113 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10114 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10115 DEFUN (__go_uicontextmenu__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10116 "-*- texinfo -*-\n\ |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10117 @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
|
10118 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10119 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10120 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10121 GO_BODY (uicontextmenu); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10122 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10123 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10124 DEFUN (__go_uitoolbar__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10125 "-*- texinfo -*-\n\ |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10126 @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
|
10127 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10128 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10129 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10130 GO_BODY (uitoolbar); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10131 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10132 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10133 DEFUN (__go_uipushtool__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10134 "-*- texinfo -*-\n\ |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10135 @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
|
10136 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10137 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10138 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10139 GO_BODY (uipushtool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10140 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10141 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10142 DEFUN (__go_uitoggletool__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10143 "-*- texinfo -*-\n\ |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10144 @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
|
10145 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10146 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10147 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10148 GO_BODY (uitoggletool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10149 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
10150 |
6406 | 10151 DEFUN (__go_delete__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10152 "-*- texinfo -*-\n\ |
6406 | 10153 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ |
6945 | 10154 Undocumented internal function.\n\ |
6406 | 10155 @end deftypefn") |
10156 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10157 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10158 |
6406 | 10159 octave_value_list retval; |
10160 | |
10161 if (args.length () == 1) | |
10162 { | |
10163 graphics_handle h = octave_NaN; | |
10164 | |
18111
b560bac0fca2
maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents:
18099
diff
changeset
|
10165 const NDArray vals = args(0).array_value (); |
6406 | 10166 |
10167 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10168 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10169 // Check is all the handles to delete are valid first |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10170 // as callbacks might delete one of the handles we |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10171 // later want to delete |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10172 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
|
10173 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10174 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10175 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10176 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10177 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
10178 error ("delete: invalid graphics object (= %g)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10179 vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10180 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10181 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10182 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10183 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10184 if (! error_state) |
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
|
10185 delete_graphics_objects (vals); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10186 } |
6406 | 10187 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10188 error ("delete: invalid graphics object"); |
6406 | 10189 } |
10190 else | |
10191 print_usage (); | |
10192 | |
10193 return retval; | |
10194 } | |
10195 | |
10196 DEFUN (__go_axes_init__, args, , | |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10197 "-*- texinfo -*-\n\ |
6406 | 10198 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ |
6945 | 10199 Undocumented internal function.\n\ |
6406 | 10200 @end deftypefn") |
10201 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10202 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10203 |
6406 | 10204 octave_value retval; |
10205 | |
10206 int nargin = args.length (); | |
10207 | |
10208 std::string mode = ""; | |
10209 | |
10210 if (nargin == 2) | |
10211 { | |
10212 mode = args(1).string_value (); | |
10213 | |
10214 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10215 return retval; |
6406 | 10216 } |
10217 | |
10218 if (nargin == 1 || nargin == 2) | |
10219 { | |
10220 graphics_handle h = octave_NaN; | |
10221 | |
10222 double val = args(0).double_value (); | |
10223 | |
10224 if (! error_state) | |
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 h = gh_manager::lookup (val); |
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 if (h.ok ()) |
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 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10231 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10232 obj.set_defaults (mode); |
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 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10235 if (! h.ok ()) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10236 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
|
10237 val); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10238 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10239 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10240 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
|
10241 } |
6406 | 10242 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10243 error ("__go_axes_init__: invalid graphics object"); |
6406 | 10244 } |
10245 else | |
10246 print_usage (); | |
10247 | |
10248 return retval; | |
10249 } | |
10250 | |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10251 DEFUN (__go_handles__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10252 "-*- texinfo -*-\n\ |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10253 @deftypefn {Built-in Function} {} __go_handles__ (@var{show_hidden})\n\ |
6945 | 10254 Undocumented internal function.\n\ |
6406 | 10255 @end deftypefn") |
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 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10259 bool show_hidden = false; |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10260 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10261 if (args.length () > 0) |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10262 show_hidden = args(0).bool_value (); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10263 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10264 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
|
10265 } |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10266 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10267 DEFUN (__go_figure_handles__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10268 "-*- texinfo -*-\n\ |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10269 @deftypefn {Built-in Function} {} __go_figure_handles__ (@var{show_hidden})\n\ |
6945 | 10270 Undocumented internal function.\n\ |
6425 | 10271 @end deftypefn") |
10272 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10273 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10274 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10275 bool show_hidden = false; |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10276 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10277 if (args.length () > 0) |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10278 show_hidden = args(0).bool_value (); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10279 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10280 return octave_value (gh_manager::figure_handle_list (show_hidden)); |
6406 | 10281 } |
10282 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10283 DEFUN (__go_execute_callback__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10284 "-*- texinfo -*-\n\ |
10840 | 10285 @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
|
10286 @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
|
10287 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10288 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10289 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10290 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10291 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10292 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10293 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10294 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10295 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10296 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10297 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10298 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10299 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10300 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10301 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10302 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10303 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10304 std::string name = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10305 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10306 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10307 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10308 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10309 gh_manager::execute_callback (h, name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10310 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10311 gh_manager::execute_callback (h, name, args(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10312 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10313 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10314 error ("__go_execute_callback__: invalid callback name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10315 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10316 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10317 error ("__go_execute_callback__: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10318 val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10319 } |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10320 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10321 error ("__go_execute_callback__: invalid graphics object"); |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10322 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10323 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10324 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10325 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10326 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10327 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
10328 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10329 DEFUN (__image_pixel_size__, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10330 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
10331 @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
|
10332 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
|
10333 @end deftypefn") |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10334 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10335 octave_value retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10336 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10337 int nargin = args.length (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10338 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10339 if (nargin == 1) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10340 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10341 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
|
10342 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10343 if (! error_state) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10344 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10345 graphics_object fobj = gh_manager::get_object (h); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10346 if (fobj && fobj.isa ("image")) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10347 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10348 image::properties& ip = |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10349 dynamic_cast<image::properties&> (fobj.get_properties ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
10350 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10351 Matrix dp = Matrix (1, 2, 0); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10352 dp(0, 0) = ip.pixel_xsize (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10353 dp(0, 1) = ip.pixel_ysize (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10354 retval = dp; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10355 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10356 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10357 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
|
10358 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10359 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10360 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
|
10361 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10362 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10363 print_usage (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10364 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10365 return retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10366 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
10367 |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10368 gtk_manager *gtk_manager::instance = 0; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10369 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10370 void |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10371 gtk_manager::create_instance (void) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10372 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10373 instance = new gtk_manager (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10374 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10375 if (instance) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10376 singleton_cleanup_list::add (cleanup_instance); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10377 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10378 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10379 graphics_toolkit |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10380 gtk_manager::do_get_toolkit (void) const |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10381 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10382 graphics_toolkit retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10383 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10384 const_loaded_toolkits_iterator pl = loaded_toolkits.find (dtk); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10385 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10386 if (pl == loaded_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10387 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10388 const_available_toolkits_iterator pa = available_toolkits.find (dtk); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10389 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10390 if (pa != available_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10391 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10392 octave_value_list args; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10393 args(0) = dtk; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10394 feval ("graphics_toolkit", args); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10395 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10396 if (! error_state) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10397 pl = loaded_toolkits.find (dtk); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10398 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10399 if (error_state || pl == loaded_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10400 error ("failed to load %s graphics toolkit", dtk.c_str ()); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10401 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10402 retval = pl->second; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10403 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10404 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
10405 error ("default graphics toolkit '%s' is not available!", |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10406 dtk.c_str ()); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10407 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10408 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10409 retval = pl->second; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10410 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10411 return retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10412 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10413 |
18653
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10414 void |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10415 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:
18566
diff
changeset
|
10416 { |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10417 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:
18566
diff
changeset
|
10418 || (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:
18566
diff
changeset
|
10419 && 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:
18566
diff
changeset
|
10420 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:
18566
diff
changeset
|
10421 |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10422 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:
18566
diff
changeset
|
10423 } |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10424 |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10425 void |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10426 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:
18566
diff
changeset
|
10427 { |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10428 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:
18566
diff
changeset
|
10429 |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10430 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:
18566
diff
changeset
|
10431 { |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10432 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:
18566
diff
changeset
|
10433 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:
18566
diff
changeset
|
10434 else |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10435 { |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10436 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:
18566
diff
changeset
|
10437 |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10438 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:
18566
diff
changeset
|
10439 |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10440 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:
18566
diff
changeset
|
10441 { |
18835 | 10442 std::string tk_name = *pa++; |
10443 | |
10444 if (tk_name == "qt" | |
10445 || (tk_name == "fltk" | |
10446 && available_toolkits.find ("qt") | |
10447 == available_toolkits.end ())) | |
10448 dtk = tk_name; | |
18653
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10449 } |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10450 } |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10451 } |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10452 } |
ca1648b2e673
set default toolkit when registering toolkits (bug #41665).
Michael C. Grant <mcg@cvxr.com> and John W. Eaton <jwe@octave.org>
parents:
18566
diff
changeset
|
10453 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
10454 DEFUN (available_graphics_toolkits, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10455 "-*- texinfo -*-\n\ |
12215
4ae2a74ed04c
Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12189
diff
changeset
|
10456 @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
|
10457 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
|
10458 @seealso{graphics_toolkit, register_graphics_toolkit}\n\ |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
10459 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
10460 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10461 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10462 |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10463 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
|
10464 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10465 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10466 DEFUN (register_graphics_toolkit, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10467 "-*- texinfo -*-\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10468 @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
|
10469 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
|
10470 @seealso{available_graphics_toolkits}\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10471 @end deftypefn") |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10472 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10473 octave_value retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10474 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10475 gh_manager::auto_lock guard; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10476 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10477 if (args.length () == 1) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10478 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10479 std::string name = args(0).string_value (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10480 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10481 if (! error_state) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10482 gtk_manager::register_toolkit (name); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10483 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10484 error ("register_graphics_toolkit: expecting character string"); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10485 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10486 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10487 print_usage (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10488 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10489 return retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10490 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10491 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10492 DEFUN (loaded_graphics_toolkits, , , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10493 "-*- texinfo -*-\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10494 @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
|
10495 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
|
10496 @seealso{available_graphics_toolkits}\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10497 @end deftypefn") |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10498 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10499 gh_manager::auto_lock guard; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10500 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
10501 return octave_value (gtk_manager::loaded_toolkits_list ()); |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
10502 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
10503 |
7408 | 10504 DEFUN (drawnow, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10505 "-*- texinfo -*-\n\ |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10506 @deftypefn {Built-in Function} {} drawnow ()\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10507 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10508 @deftypefnx {Built-in Function} {} drawnow (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10509 Update figure windows and their children. The event queue is flushed and\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10510 any callbacks generated are executed. With the optional argument\n\ |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17269
diff
changeset
|
10511 @qcode{\"expose\"}, only graphic objects are updated and no other events or\n\ |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10512 callbacks are processed.\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
10513 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
|
10514 undocumented.\n\ |
7408 | 10515 @end deftypefn") |
10516 { | |
10517 static int drawnow_executing = 0; | |
10518 | |
10519 octave_value retval; | |
10520 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10521 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10522 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
10523 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
10524 frame.protect_var (Vdrawnow_requested, false); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
10525 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
10526 frame.protect_var (drawnow_executing); |
7409 | 10527 |
10528 if (++drawnow_executing <= 1) | |
7408 | 10529 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10530 if (args.length () == 0 || args.length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10531 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
10532 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
|
10533 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10534 for (int i = 0; ! error_state && i < hlist.length (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10535 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10536 graphics_handle h = gh_manager::lookup (hlist(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10537 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10538 if (h.ok () && h != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10539 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10540 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
|
10541 figure::properties& fprops |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10542 = dynamic_cast <figure::properties&> (go.get_properties ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10543 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10544 if (fprops.is_modified ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10545 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10546 if (fprops.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10547 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10548 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10549 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
10550 fprops.get_toolkit ().redraw_figure (go); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10551 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10552 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10553 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10554 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10555 fprops.set_modified (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10556 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10557 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10558 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10559 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10560 bool do_events = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10561 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10562 if (args.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10563 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10564 caseless_str val (args(0).string_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10565 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10566 if (! error_state && val.compare ("expose")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10567 do_events = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10568 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10569 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
10570 error ("drawnow: invalid argument, expected 'expose' as argument"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10571 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10572 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10573 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10574 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10575 if (do_events) |
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 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10578 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10579 gh_manager::process_events (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10580 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10581 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10582 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10583 } |
7409 | 10584 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
|
10585 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10586 std::string term, file, debug_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10587 bool mono; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10588 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10589 term = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10590 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10591 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10592 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10593 file = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10594 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10595 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10596 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10597 size_t pos = file.find_first_not_of ("|"); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10598 if (pos > 0) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10599 file = file.substr (pos); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10600 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10601 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10602 pos = file.find_last_of (file_ops::dir_sep_chars ()); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10603 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10604 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10605 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10606 std::string dirname = file.substr (0, pos+1); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10607 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10608 file_stat fs (dirname); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10609 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10610 if (! (fs && fs.is_dir ())) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10611 { |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
10612 error ("drawnow: nonexistent directory '%s'", |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10613 dirname.c_str ()); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10614 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10615 return retval; |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
10616 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10617 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10618 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10619 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10620 mono = (args.length () >= 3 ? args(2).bool_value () : false); |
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 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10623 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10624 debug_file = (args.length () > 3 ? args(3).string_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10625 : ""); |
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 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10628 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10629 graphics_handle h = gcf (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10630 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10631 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10632 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10633 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10634 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10635 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10636 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10637 go.get_toolkit ().print_figure (go, term, file, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10638 mono, debug_file); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10639 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10640 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10641 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10642 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10643 error ("drawnow: nothing to draw"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10644 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10645 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10646 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
|
10647 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10648 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10649 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
|
10650 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10651 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10652 error ("drawnow: invalid FILE, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10653 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10654 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10655 error ("drawnow: invalid terminal TERM, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10656 } |
7408 | 10657 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10658 print_usage (); |
7408 | 10659 } |
7409 | 10660 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10661 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10662 |
7408 | 10663 return retval; |
10664 } | |
10665 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
10666 DEFUN (addlistener, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10667 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
10668 @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
|
10669 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10670 object @var{h}. Property listeners are executed (in order of registration)\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10671 when the property is set. The new value is already available when the\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10672 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10673 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10674 @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
|
10675 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10676 @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
|
10677 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
|
10678 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
|
10679 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
|
10680 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
|
10681 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
|
10682 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
|
10683 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
|
10684 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10685 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10686 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10687 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
10688 @group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10689 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
|
10690 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
|
10691 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10692 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
10693 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
|
10694 @end group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10695 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10696 \n\ |
17486
b4343603f7ab
doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents:
17483
diff
changeset
|
10697 @seealso{addproperty, hggroup}\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10698 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10699 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10700 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10701 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10702 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10703 |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10704 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
|
10705 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10706 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10707 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10708 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10709 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10710 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10711 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10712 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10713 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10714 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10715 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10716 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10717 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10718 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10719 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10720 go.add_property_listener (pname, args(2), POSTSET); |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10721 |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10722 if (args.length () == 4) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10723 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10724 caseless_str persistent = args(3).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10725 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10726 go.add_property_listener (pname, args(2), PERSISTENT); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10727 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10728 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10729 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10730 error ("addlistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10731 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10732 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10733 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10734 error ("addlistener: invalid property name, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10735 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10736 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10737 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10738 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10739 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10740 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10741 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10742 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10743 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
10744 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10745 DEFUN (dellistener, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10746 "-*- 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
|
10747 @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
|
10748 Remove the registration of @var{fcn} as a listener for the property\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10749 @var{prop} of the graphics object @var{h}. The function @var{fcn} must\n\ |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10750 be the same variable (not just the same value), as was passed to the\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10751 original call to @code{addlistener}.\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10752 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10753 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
|
10754 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
|
10755 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10756 Example:\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10757 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10758 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
10759 @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
|
10760 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
|
10761 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
|
10762 endfunction\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10763 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10764 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
|
10765 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
|
10766 dellistener (gcf, \"position\", c);\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
10767 @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
|
10768 @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
|
10769 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10770 @end deftypefn") |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10771 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10772 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
|
10773 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10774 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
|
10775 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10776 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
|
10777 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10778 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
|
10779 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10780 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10781 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10782 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10783 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10784 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10785 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10786 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10787 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10788 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10789 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10790 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10791 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10792 if (args.length () == 2) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10793 go.delete_property_listener (pname, octave_value (), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10794 POSTSET); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10795 else |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10796 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10797 caseless_str persistent = args(2).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10798 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10799 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10800 go.delete_property_listener (pname, octave_value (), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10801 PERSISTENT); |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10802 go.delete_property_listener (pname, octave_value (), |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10803 POSTSET); |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10804 } |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10805 else |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10806 go.delete_property_listener (pname, args(2), POSTSET); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
10807 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10808 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10809 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10810 error ("dellistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10811 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10812 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10813 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10814 error ("dellistener: invalid property name, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10815 } |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10816 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10817 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
|
10818 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10819 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10820 print_usage (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10821 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10822 return retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10823 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
10824 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10825 DEFUN (addproperty, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
10826 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
10827 @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
|
10828 @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
|
10829 Create a new property named @var{name} in graphics object @var{h}.\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10830 @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
|
10831 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
|
10832 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
|
10833 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10834 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10835 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10836 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10837 @item string\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10838 A string property. @var{arg} contains the default string value.\n\ |
10840 | 10839 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10840 @item any\n\ |
16826
a4969508008e
doc: Periodic spellcheck of the documentation.
Rik <rik@octave.org>
parents:
16814
diff
changeset
|
10841 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
|
10842 value. @var{args} contains the default value.\n\ |
10840 | 10843 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10844 @item radio\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10845 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
|
10846 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
|
10847 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
|
10848 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
|
10849 an optional second string argument.\n\ |
10840 | 10850 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10851 @item boolean\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10852 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
|
10853 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
|
10854 the default property value.\n\ |
10840 | 10855 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10856 @item double\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10857 A scalar double property. @var{arg} contains the default value.\n\ |
10840 | 10858 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10859 @item handle\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10860 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
|
10861 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
|
10862 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
|
10863 the empty matrix.\n\ |
10840 | 10864 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10865 @item data\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10866 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
|
10867 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
|
10868 the empty matrix.\n\ |
10840 | 10869 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10870 @item color\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10871 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
|
10872 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
|
10873 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
|
10874 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
|
10875 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10876 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10877 @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
|
10878 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
|
10879 then has the same characteristics as the referenced property (type,\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
10880 possible values, hidden state@dots{}). This allows to clone an existing\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10881 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10882 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10883 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10884 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10885 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
10886 @group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10887 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10888 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
|
10889 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
10890 @end group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10891 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10892 \n\ |
17486
b4343603f7ab
doc: Add seealso links between hggroup, addproperty, addlistener.
Rik <rik@octave.org>
parents:
17483
diff
changeset
|
10893 @seealso{addlistener, hggroup}\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10894 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10895 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10896 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10897 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10898 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10899 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10900 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10901 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10902 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10903 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10904 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10905 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10906 double h = args(1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10907 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10908 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10909 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10910 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10911 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10912 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10913 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10914 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10915 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10916 std::string type = args(2).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10917 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10918 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10919 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10920 if (! go.get_properties ().has_property (name)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10921 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10922 property p = property::create (name, gh, type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10923 args.splice (0, 3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10924 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10925 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10926 go.get_properties ().insert_property (name, p); |
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 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
10929 error ("addproperty: a '%s' property already exists in the graphics object", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10930 name.c_str ()); |
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 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10933 error ("addproperty: invalid property TYPE, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10934 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10935 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10936 error ("addproperty: invalid graphics object (= %g)", h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10937 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10938 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10939 error ("addproperty: invalid handle value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10940 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10941 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
10942 error ("addproperty: invalid property NAME, expected a string value"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10943 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10944 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10945 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10946 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10947 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10948 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
10949 |
6595 | 10950 octave_value |
7447 | 10951 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
|
10952 const std::string& func) |
6595 | 10953 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10954 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10955 |
6595 | 10956 graphics_object obj = gh_manager::get_object (handle); |
10957 octave_value retval; | |
10958 | |
10959 if (obj) | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
10960 retval = obj.get (caseless_str (property)); |
6595 | 10961 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
|
10962 error ("%s: invalid handle (= %g)", func.c_str (), handle); |
6595 | 10963 |
10964 return retval; | |
10965 } | |
10966 | |
10967 bool | |
7447 | 10968 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
|
10969 const octave_value& arg, const std::string& func) |
6595 | 10970 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
10971 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
10972 |
6595 | 10973 graphics_object obj = gh_manager::get_object (handle); |
10974 int ret = false; | |
10975 | |
10976 if (obj) | |
10977 { | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
10978 obj.set (caseless_str (property), arg); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
10979 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
10980 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
10981 ret = true; |
6595 | 10982 } |
10983 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
|
10984 error ("%s: invalid handle (= %g)", func.c_str (), handle); |
6595 | 10985 |
10986 return ret; | |
10987 } | |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10988 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10989 static bool |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10990 compare_property_values (const octave_value& o1, const octave_value& o2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10991 { |
18111
b560bac0fca2
maint: Don't use space between 'args' and '(' when doing indexing.
Rik <rik@octave.org>
parents:
18099
diff
changeset
|
10992 octave_value_list args(2); |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10993 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10994 args(0) = o1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10995 args(1) = o2; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10996 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10997 octave_value_list result = feval ("isequal", args, 1); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10998 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
10999 if (! error_state && result.length () > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11000 return result(0).bool_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11001 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11002 return false; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11003 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11004 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11005 static std::map<uint32_t, bool> waitfor_results; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11006 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11007 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11008 cleanup_waitfor_id (uint32_t id) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11009 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11010 waitfor_results.erase (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11011 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11012 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11013 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11014 do_cleanup_waitfor_listener (const octave_value& listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11015 listener_mode mode = POSTSET) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11016 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11017 Cell c = listener.cell_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11018 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11019 if (c.numel () >= 4) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11020 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11021 double h = c(2).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11022 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11023 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11024 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11025 caseless_str pname = c(3).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11026 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11027 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11028 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11029 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11030 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11031 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11032 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11033 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11034 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11035 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11036 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11037 if (go.get_properties ().has_property (pname)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11038 { |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11039 go.get_properties ().delete_listener (pname, listener, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11040 mode); |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11041 if (mode == POSTSET) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11042 go.get_properties ().delete_listener (pname, listener, |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11043 PERSISTENT); |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11044 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11045 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11046 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11047 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11048 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11049 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11050 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11051 static void |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
11052 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
|
11053 { do_cleanup_waitfor_listener (listener, POSTSET); } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11054 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11055 static void |
14861
f7afecdd87ef
maint: Use Octave coding conventions for cuddling parentheses in src/ directory
Rik <octave@nomad.inbox5.com>
parents:
14846
diff
changeset
|
11056 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
|
11057 { do_cleanup_waitfor_listener (listener, PREDELETE); } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11058 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11059 static octave_value_list |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11060 waitfor_listener (const octave_value_list& args, int) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11061 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11062 if (args.length () > 3) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11063 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11064 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
|
11065 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11066 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11067 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11068 if (args.length () > 5) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11069 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11070 double h = args(0).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11071 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11072 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11073 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11074 caseless_str pname = args(4).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11075 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11076 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11077 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11078 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11079 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11080 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11081 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11082 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11083 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11084 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11085 octave_value pvalue = go.get (pname); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11086 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11087 if (compare_property_values (pvalue, args(5))) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11088 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11089 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11090 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11091 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11092 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11093 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11094 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11095 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11096 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11097 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11098 return octave_value_list (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11099 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11100 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11101 static octave_value_list |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11102 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
|
11103 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11104 if (args.length () > 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11105 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11106 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
|
11107 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11108 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11109 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11110 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11111 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11112 return octave_value_list (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11113 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11114 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11115 DEFUN (waitfor, args, , |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11116 "-*- texinfo -*-\n\ |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11117 @deftypefn {Built-in Function} {} waitfor (@var{h})\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11118 @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
|
11119 @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
|
11120 @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
|
11121 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
|
11122 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
|
11123 \n\ |
710309214e0d
doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents:
17443
diff
changeset
|
11124 While the program is suspended graphics events are still being processed\n\ |
710309214e0d
doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents:
17443
diff
changeset
|
11125 normally, allowing callbacks to modify the state of graphics objects. This\n\ |
710309214e0d
doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents:
17443
diff
changeset
|
11126 function is reentrant and can be called from a callback, while another\n\ |
710309214e0d
doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents:
17443
diff
changeset
|
11127 @code{waitfor} 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
|
11128 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11129 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
|
11130 @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
|
11131 returns immediately.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11132 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11133 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
|
11134 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
|
11135 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
|
11136 immediately.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11137 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11138 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
|
11139 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
|
11140 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
|
11141 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
|
11142 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
|
11143 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11144 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
|
11145 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
|
11146 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
|
11147 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
|
11148 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
|
11149 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11150 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
|
11151 @code{\\timeout} instead.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11152 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11153 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
|
11154 @seealso{waitforbuttonpress, isequal}\n\ |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11155 @end deftypefn") |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11156 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11157 if (args.length () > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11158 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11159 double h = args(0).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11160 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11161 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11162 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11163 caseless_str pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11164 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11165 unwind_protect frame; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11166 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11167 static uint32_t id_counter = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11168 uint32_t id = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11169 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11170 int max_arg_index = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11171 int timeout_index = -1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11172 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11173 int timeout = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11174 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11175 if (args.length () > 1) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11176 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11177 pname = args(1).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11178 if (! error_state |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11179 && ! pname.empty () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11180 && ! pname.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11181 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11182 if (pname.compare ("\\timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11183 pname = "timeout"; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11184 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11185 static octave_value wf_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11186 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11187 if (! wf_listener.is_defined ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11188 wf_listener = |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11189 octave_value (new octave_builtin (waitfor_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11190 "waitfor_listener")); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11191 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11192 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11193 if (args.length () > 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11194 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11195 if (args(2).is_string ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11196 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11197 caseless_str s = args(2).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11198 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11199 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11200 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11201 if (s.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11202 timeout_index = 2; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11203 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11204 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11205 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11206 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11207 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11208 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11209 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11210 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11211 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
|
11212 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11213 id = id_counter++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11214 frame.add_fcn (cleanup_waitfor_id, id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11215 waitfor_results[id] = false; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11216 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11217 listener(0) = wf_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11218 listener(1) = octave_uint32 (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11219 listener(2) = h; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11220 listener(3) = pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11221 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11222 if (max_arg_index >= 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11223 listener(4) = args(2); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11224 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11225 octave_value ov_listener (listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11226 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11227 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11228 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11229 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11230 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11231 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11232 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11233 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11234 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11235 if (max_arg_index >= 2 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11236 && compare_property_values (go.get (pname), |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11237 args(2))) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11238 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11239 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11240 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11241 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11242 frame.add_fcn (cleanup_waitfor_postset_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11243 ov_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11244 go.add_property_listener (pname, ov_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11245 POSTSET); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11246 go.add_property_listener (pname, ov_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11247 PERSISTENT); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11248 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11249 if (go.get_properties () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11250 .has_dynamic_property (pname)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11251 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11252 static octave_value wf_del_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11253 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11254 if (! wf_del_listener.is_defined ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11255 wf_del_listener = |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11256 octave_value (new octave_builtin |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11257 (waitfor_del_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11258 "waitfor_del_listener")); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11259 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11260 Cell del_listener (1, 4); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11261 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11262 del_listener(0) = wf_del_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11263 del_listener(1) = octave_uint32 (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11264 del_listener(2) = h; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11265 del_listener(3) = pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11266 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11267 octave_value ov_del_listener (del_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11268 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11269 frame.add_fcn (cleanup_waitfor_predelete_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11270 ov_del_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11271 go.add_property_listener (pname, ov_del_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11272 PREDELETE); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11273 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11274 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11275 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11276 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11277 else if (error_state || pname.empty ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11278 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
|
11279 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11280 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11281 if (! error_state |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11282 && timeout_index < 0 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11283 && args.length () > (max_arg_index + 1)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11284 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11285 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
|
11286 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11287 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11288 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11289 if (s.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11290 timeout_index = max_arg_index + 1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11291 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
11292 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
|
11293 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11294 else |
15466
d174210ce1ec
use ' instead of ` in error messages, warnings and most comments
John W. Eaton <jwe@octave.org>
parents:
14325
diff
changeset
|
11295 error ("waitfor: invalid parameter, expected 'timeout'"); |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11296 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11297 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11298 if (! error_state && timeout_index >= 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11299 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11300 if (args.length () > (timeout_index + 1)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11301 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11302 timeout = static_cast<int> |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
11303 (args(timeout_index + 1).scalar_value ()); |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11304 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11305 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11306 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11307 if (timeout < 1) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11308 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11309 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
|
11310 timeout = 1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11311 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11312 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11313 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11314 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
|
11315 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11316 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11317 error ("waitfor: missing timeout value"); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11318 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11319 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11320 // 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
|
11321 // assumes that an object handle is unique, which is a fair |
17483
710309214e0d
doc: Add seealso links between waitfor, waitforbuttonpress, and ginput.
Rik <rik@octave.org>
parents:
17443
diff
changeset
|
11322 // 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
|
11323 // 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
|
11324 // run of event hooks, then the figure destruction won't be |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11325 // caught and the loop will not stop. This is an unlikely |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11326 // possibility in practice, though. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11327 // |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11328 // 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
|
11329 // 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
|
11330 // would not stop. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11331 // |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11332 // The only "good" implementation would require object |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11333 // listeners, similar to property listeners. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11334 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11335 time_t start = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11336 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11337 if (timeout > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11338 start = time (0); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11339 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11340 while (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11341 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11342 if (true) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11343 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11344 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11345 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11346 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11347 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11348 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11349 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11350 if (! pname.empty () && waitfor_results[id]) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11351 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11352 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11353 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11354 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11355 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11356 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11357 octave_usleep (100000); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11358 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11359 OCTAVE_QUIT; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11360 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11361 command_editor::run_event_hooks (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11362 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11363 if (timeout > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11364 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11365 if (start + timeout < time (0)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11366 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11367 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11368 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11369 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11370 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11371 error ("waitfor: invalid handle value."); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11372 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11373 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11374 print_usage (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11375 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11376 return octave_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
11377 } |