Mercurial > hg > octave-lyh
annotate src/graphics.cc @ 14383:07c55bceca23 stable
Fix guarded_eval() subfunction in fminunc (bug #35534).
* fminunc.m: Fix guarded_eval() subfunction in fminunc (bug #35534).
author | Olaf Till <olaf.till@uni-jena.de> |
---|---|
date | Wed, 15 Feb 2012 14:44:37 +0100 |
parents | a646cee995cf |
children | 63f1bdf08339 d174210ce1ec |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14134
diff
changeset
|
3 Copyright (C) 2007-2012 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 |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
45 #include "cutils.h" |
6705 | 46 #include "defun.h" |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
47 #include "display.h" |
6705 | 48 #include "error.h" |
6595 | 49 #include "graphics.h" |
7409 | 50 #include "input.h" |
6705 | 51 #include "ov.h" |
52 #include "oct-obj.h" | |
53 #include "oct-map.h" | |
54 #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
|
55 #include "pager.h" |
6705 | 56 #include "parse.h" |
7409 | 57 #include "toplev.h" |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
58 #include "txt-eng-ft.h" |
7222 | 59 #include "unwind-prot.h" |
6595 | 60 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
61 // 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
|
62 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
|
63 |
6406 | 64 static void |
65 gripe_set_invalid (const std::string& pname) | |
66 { | |
67 error ("set: invalid value for %s property", pname.c_str ()); | |
68 } | |
69 | |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
70 // 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
|
71 // 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
|
72 // 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
|
73 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
74 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
|
75 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
|
76 const std::set<std::string>& pnames, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
77 const caseless_str& pname) |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
78 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
79 size_t len = pname.length (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
80 std::set<std::string> matches; |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
81 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
82 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
|
83 p != pnames.end (); p++) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
84 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
85 if (pname.compare (*p, len)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
86 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
87 if (len == p->length ()) |
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 // Exact match. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
90 return pname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
91 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
92 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
93 matches.insert (*p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
94 } |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
95 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
96 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
97 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
|
98 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
99 if (num_matches == 0) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
100 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
101 error ("%s: unknown %s property %s", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
102 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
|
103 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
104 else if (num_matches > 1) |
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 string_vector sv (matches); |
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 std::ostringstream os; |
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 sv.list_in_columns (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 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
|
113 |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
114 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
|
115 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
|
116 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
117 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
|
118 { |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
119 // 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
|
120 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
121 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
|
122 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
123 warning_with_id ("Octave:abbreviated-property-match", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
124 "%s: allowing %s to match %s property %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
125 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
|
126 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
|
127 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
128 return possible_match; |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
129 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
130 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
131 return caseless_str (); |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
132 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
133 |
7363 | 134 static Matrix |
135 jet_colormap (void) | |
136 { | |
137 Matrix cmap (64, 3, 0.0); | |
138 | |
139 for (octave_idx_type i = 0; i < 64; i++) | |
140 { | |
141 // This is the jet colormap. It would be nice to be able | |
142 // to feval the jet function but since there is a static | |
143 // property object that includes a colormap_property | |
144 // object, we need to initialize this before main is even | |
145 // called, so calling an interpreted function is not | |
146 // possible. | |
147 | |
148 double x = i / 63.0; | |
149 | |
150 if (x >= 3.0/8.0 && x < 5.0/8.0) | |
151 cmap(i,0) = 4.0 * x - 3.0/2.0; | |
152 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
153 cmap(i,0) = 1.0; | |
154 else if (x >= 7.0/8.0) | |
155 cmap(i,0) = -4.0 * x + 9.0/2.0; | |
156 | |
157 if (x >= 1.0/8.0 && x < 3.0/8.0) | |
158 cmap(i,1) = 4.0 * x - 1.0/2.0; | |
159 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
160 cmap(i,1) = 1.0; | |
161 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
162 cmap(i,1) = -4.0 * x + 7.0/2.0; | |
163 | |
164 if (x < 1.0/8.0) | |
165 cmap(i,2) = 4.0 * x + 1.0/2.0; | |
166 else if (x >= 1.0/8.0 && x < 3.0/8.0) | |
167 cmap(i,2) = 1.0; | |
168 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
169 cmap(i,2) = -4.0 * x + 5.0/2.0; | |
170 } | |
171 | |
172 return cmap; | |
173 } | |
174 | |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
175 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
176 default_screendepth (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
177 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
178 return display_info::depth (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
179 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
180 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
181 static Matrix |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
182 default_screensize (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 Matrix retval (1, 4, 1.0); |
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 retval(2) = display_info::width (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
187 retval(3) = display_info::height (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
188 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
189 return retval; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
190 } |
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 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
193 default_screenpixelsperinch (void) |
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 (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
|
196 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
197 |
7363 | 198 static Matrix |
199 default_colororder (void) | |
200 { | |
201 Matrix retval (7, 3, 0.0); | |
202 | |
203 retval(0,2) = 1.0; | |
204 | |
205 retval(1,1) = 0.5; | |
206 | |
207 retval(2,0) = 1.0; | |
208 | |
209 retval(3,1) = 0.75; | |
210 retval(3,2) = 0.75; | |
211 | |
212 retval(4,0) = 0.75; | |
213 retval(4,2) = 0.75; | |
214 | |
215 retval(5,0) = 0.75; | |
216 retval(5,1) = 0.75; | |
217 | |
218 retval(6,0) = 0.25; | |
219 retval(6,1) = 0.25; | |
220 retval(6,2) = 0.25; | |
221 | |
222 return retval; | |
223 } | |
224 | |
225 static Matrix | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
226 default_lim (bool logscale = false) |
7363 | 227 { |
228 Matrix m (1, 2, 0); | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
229 |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
230 if (logscale) |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
231 { |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
232 m(0) = 0.1; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
233 m(1) = 1.0; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
234 } |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
235 else |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
236 m(1) = 1; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
237 |
7363 | 238 return m; |
239 } | |
240 | |
241 static Matrix | |
242 default_data (void) | |
243 { | |
244 Matrix retval (1, 2); | |
245 | |
246 retval(0) = 0; | |
247 retval(1) = 1; | |
248 | |
249 return retval; | |
250 } | |
251 | |
7427 | 252 static Matrix |
253 default_axes_position (void) | |
254 { | |
255 Matrix m (1, 4, 0.0); | |
256 m(0) = 0.13; | |
257 m(1) = 0.11; | |
258 m(2) = 0.775; | |
259 m(3) = 0.815; | |
260 return m; | |
261 } | |
262 | |
263 static Matrix | |
264 default_axes_outerposition (void) | |
265 { | |
266 Matrix m (1, 4, 0.0); | |
267 m(2) = m(3) = 1.0; | |
268 return m; | |
269 } | |
270 | |
7445 | 271 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
272 default_axes_tick (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
273 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
274 Matrix m (1, 6, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
275 m(0) = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
276 m(1) = 0.2; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
277 m(2) = 0.4; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
278 m(3) = 0.6; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
279 m(4) = 0.8; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
280 m(5) = 1.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
281 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
282 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
283 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
284 static Matrix |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
285 default_axes_ticklength (void) |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
286 { |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
287 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
|
288 m(0) = 0.01; |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
289 m(1) = 0.025; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
290 return m; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
291 } |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
292 |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
293 static Matrix |
7445 | 294 default_figure_position (void) |
295 { | |
296 Matrix m (1, 4, 0.0); | |
297 m(0) = 300; | |
298 m(1) = 200; | |
299 m(2) = 560; | |
300 m(3) = 420; | |
301 return m; | |
302 } | |
303 | |
7427 | 304 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
305 default_figure_papersize (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
306 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
307 Matrix m (1, 2, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
308 m(0) = 8.5; |
8961
6b87f2f34fdd
graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents:
8944
diff
changeset
|
309 m(1) = 11.0; |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
310 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
311 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
312 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
313 static Matrix |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
314 default_figure_paperposition (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
315 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
316 Matrix m (1, 4, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
317 m(0) = 0.25; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
318 m(1) = 2.50; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
319 m(2) = 8.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
320 m(3) = 6.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
321 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
322 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
323 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
324 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
|
325 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
|
326 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
327 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
|
328 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
329 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
|
330 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
|
331 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
|
332 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
|
333 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
334 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
335 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
336 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
337 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
338 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
|
339 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
340 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
|
341 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
342 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
|
343 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
|
344 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
345 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
346 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
347 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
348 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
349 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
|
350 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
351 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
|
352 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
353 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
|
354 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
|
355 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
|
356 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
|
357 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
358 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
359 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
360 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
361 static double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
362 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
|
363 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
|
364 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
365 // 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
|
366 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
367 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
|
368 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
|
369 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
370 // 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
|
371 // <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
|
372 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
373 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
|
374 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
|
375 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
376 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
|
377 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
|
378 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
379 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
380 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
|
381 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
382 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
|
383 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
|
384 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
|
385 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
|
386 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
|
387 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
|
388 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
|
389 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
|
390 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
391 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
392 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
|
393 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
394 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
|
395 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
|
396 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
397 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
398 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
|
399 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
|
400 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 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
|
408 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
409 // 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
|
410 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
411 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
|
412 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
|
413 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
414 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
415 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
416 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
|
417 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
418 |
13804
4f112bebd474
use correct method to get window position for fltk
John W. Eaton <jwe@octave.org>
parents:
13801
diff
changeset
|
419 static Matrix |
7427 | 420 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
|
421 const caseless_str& to_units, const Matrix& parent_dim) |
7427 | 422 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
423 Matrix retval (1, pos.numel ()); |
7427 | 424 double res = 0; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
425 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
|
426 bool is_2d = (pos.numel () == 2); |
7427 | 427 |
428 if (from_units.compare ("pixels")) | |
429 retval = pos; | |
430 else if (from_units.compare ("normalized")) | |
431 { | |
432 retval(0) = pos(0) * parent_dim(0) + 1; | |
433 retval(1) = pos(1) * parent_dim(1) + 1; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
434 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
435 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
436 retval(2) = pos(2) * parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
437 retval(3) = pos(3) * parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
438 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
439 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
440 retval(2) = 0; |
7427 | 441 } |
442 else if (from_units.compare ("characters")) | |
443 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
444 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
445 res = xget (0, "screenpixelsperinch").double_value (); |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
446 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
447 double f = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
448 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
449 // FIXME -- this assumes the system font is Helvetica 10pt |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
450 // (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
|
451 f = 12.0 * res / 74.951; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
452 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
453 if (f > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
454 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
455 retval(0) = 0.5 * pos(0) * f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
456 retval(1) = pos(1) * f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
457 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
458 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
459 retval(2) = 0.5 * pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
460 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
461 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
462 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
463 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
464 } |
7427 | 465 } |
466 else | |
467 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
468 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
469 res = xget (0, "screenpixelsperinch").double_value (); |
7427 | 470 |
471 double f = 0.0; | |
472 | |
473 if (from_units.compare ("points")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
474 f = res / 72.0; |
7427 | 475 else if (from_units.compare ("inches")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
476 f = res; |
7427 | 477 else if (from_units.compare ("centimeters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
478 f = res / 2.54; |
7427 | 479 |
480 if (f > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
481 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
482 retval(0) = pos(0) * f + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
483 retval(1) = pos(1) * f + 1; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
484 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
485 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
486 retval(2) = pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
487 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
488 } |
13281
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 (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
490 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
491 } |
7427 | 492 } |
493 | |
494 if (! to_units.compare ("pixels")) | |
495 { | |
496 if (to_units.compare ("normalized")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
497 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
498 retval(0) = (retval(0) - 1) / parent_dim(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
499 retval(1) = (retval(1) - 1) / parent_dim(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
500 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
501 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
502 retval(2) /= parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
503 retval(3) /= parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
504 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
505 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
506 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
507 } |
7427 | 508 else if (to_units.compare ("characters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
509 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
510 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
511 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
512 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
513 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
514 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
515 f = 12.0 * res / 74.951; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
516 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
517 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
518 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
519 retval(0) = 2 * retval(0) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
520 retval(1) = retval(1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
521 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
522 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
523 retval(2) = 2 * retval(2) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
524 retval(3) = retval(3) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
525 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
526 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
527 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
528 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
529 } |
7427 | 530 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
531 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
532 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
533 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
534 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
535 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
536 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
537 if (to_units.compare ("points")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
538 f = res / 72.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
539 else if (to_units.compare ("inches")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
540 f = res; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
541 else if (to_units.compare ("centimeters")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
542 f = res / 2.54; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
543 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
544 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
545 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
546 retval(0) = (retval(0) - 1) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
547 retval(1) = (retval(1) - 1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
548 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
549 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
550 retval(2) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
551 retval(3) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
552 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
553 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
554 retval(2) = 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 } |
7427 | 557 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
558 else if (! is_rectangle && ! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
559 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
560 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
561 return retval; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
562 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
563 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
564 static Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
565 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
|
566 const caseless_str& from_units, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
567 const caseless_str& to_units) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
568 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
569 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
|
570 graphics_object ax = go.get_ancestor ("axes"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
571 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
572 Matrix retval; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
573 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
574 if (ax.valid_object ()) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
575 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
576 const axes::properties& ax_props = |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
577 dynamic_cast<const axes::properties&> (ax.get_properties ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
578 graphics_xform ax_xform = ax_props.get_transform (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
579 bool is_rectangle = (pos.numel () == 4); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
580 Matrix ax_bbox = ax_props.get_boundingbox (true), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
581 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
|
582 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
583 if (from_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
584 { |
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 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
|
588 v2 = ax_xform.transform (pos(0) + pos(2), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
589 pos(1) + pos(3), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
590 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
591 retval.resize (1, 4); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
592 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
593 retval(0) = v1(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
594 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
|
595 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
596 retval(3) = v1(1) - v2(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
597 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
598 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
599 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
600 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
|
601 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
602 retval.resize (1, 3); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
603 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
604 retval(0) = v(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
605 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
|
606 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
607 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
608 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
609 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
610 retval = convert_position (pos, from_units, "pixels", ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
611 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
612 if (! to_units.compare ("pixels")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
613 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
614 if (to_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
615 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
616 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
617 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
618 ColumnVector v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
619 ax_bbox(1) + ax_bbox(3) - retval(1) + 1), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
620 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
621 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
622 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
623 retval.resize (1, 4); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
624 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
625 retval(0) = v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
626 retval(1) = v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
627 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
628 retval(3) = v2(1) - v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
629 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
630 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
631 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
632 ColumnVector v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
633 ax_bbox(1) + ax_bbox(3) - retval(1) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
634 |
13876
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
635 retval.resize (1, 3); |
c1b072ef1fc7
avoid writing outside bounds of matrix
John W. Eaton <jwe@octave.org>
parents:
13849
diff
changeset
|
636 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
637 retval(0) = v(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
638 retval(1) = v(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
639 retval(2) = v(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
640 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
641 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
642 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
643 retval = convert_position (retval, "pixels", to_units, ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
644 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
645 } |
7427 | 646 |
647 return retval; | |
648 } | |
649 | |
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
|
650 // 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
|
651 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
|
652 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
|
653 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
654 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
|
655 Matrix sz = obj.get ("screensize").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
|
656 return convert_position (sz, obj.get ("units").string_value (), "pixels", sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
657 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
658 |
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
|
659 static void |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
660 convert_cdata_2 (bool is_scaled, double clim_0, double 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
|
661 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
|
662 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
|
663 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
664 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
|
665 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - 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
|
666 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
|
667 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
|
668 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
669 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
|
670 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
671 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
|
672 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
|
673 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
|
674 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
675 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
|
676 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
677 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
|
678 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
|
679 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
|
680 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
|
681 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
682 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
|
683 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
684 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
|
685 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
|
686 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
|
687 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
688 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
689 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
690 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
|
691 void |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
692 convert_cdata_1 (bool is_scaled, double clim_0, double 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
|
693 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
|
694 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
|
695 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
696 for (octave_idx_type i = 0; i < lda; i++) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
697 convert_cdata_2 (is_scaled, clim_0, clim_1, cmapv, cv[i], lda, nc, i, 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
|
698 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
699 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
700 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
701 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
|
702 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
|
703 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
704 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
|
705 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
706 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
|
707 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
708 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
709 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
|
710 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
|
711 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
712 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
|
713 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
|
714 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
715 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
716 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
717 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
|
718 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
719 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
720 cmap = _cmap; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
721 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
722 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
723 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
724 { |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
725 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
|
726 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
727 if (ax.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
728 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
729 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
|
730 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
731 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
732 clim = _clim; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
733 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
734 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
735 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
736 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
737 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
738 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
739 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
740 |
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
|
741 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
|
742 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
|
743 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
744 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
|
745 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
|
746 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
747 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
|
748 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
|
749 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
750 #define CONVERT_CDATA_1(ARRAY_T, VAL_FN) \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
751 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
|
752 { \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
753 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
|
754 \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
755 convert_cdata_1 (is_scaled, clim_0, clim_1, cmapv, \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
756 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
|
757 } \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
758 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
|
759 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
760 if (cdata.is_uint8_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
761 CONVERT_CDATA_1 (uint8NDArray, uint8_); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
762 else if (cdata.is_single_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
763 CONVERT_CDATA_1 (FloatNDArray, float_); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
764 else if (cdata.is_double_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
765 CONVERT_CDATA_1 (NDArray, ); |
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 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
|
767 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
|
768 |
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 #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
|
770 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
771 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
772 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
773 |
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
|
774 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
|
775 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
|
776 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
|
777 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
|
778 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
779 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
|
780 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
|
781 |
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
|
782 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
|
783 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
784 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
|
785 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
786 // 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
|
787 if (! xisinf (e)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
788 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
789 if (e < emin) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
790 emin = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
791 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
792 if (e > emax) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
793 emax = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
794 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
795 if (e > 0 && e < eminp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
796 eminp = e; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
797 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
798 if (e < 0 && e > emaxp) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
799 emaxp = e; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
800 } |
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
|
801 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
802 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
803 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
804 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
805 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
|
806 caseless_str& rest) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
807 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
808 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
809 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
810 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
811 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
812 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
813 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
814 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
815 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
816 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
817 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
818 offset = 4; |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
819 else if (len >= 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
820 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
821 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
822 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
823 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
824 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
825 else if (len >= 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
826 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
827 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
828 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
829 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
830 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
831 else if (len >= 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
832 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
833 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
834 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
835 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
|
836 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
837 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
|
838 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
|
839 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
840 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
|
841 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
842 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
843 || 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
|
844 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
845 else if (len >= 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
846 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
847 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
|
848 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
849 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
850 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
851 else if (len >= 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
852 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
853 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
|
854 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
855 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
856 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
857 else if (len >= 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
858 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
859 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
|
860 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
861 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
862 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
863 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
864 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
865 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
866 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
867 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
868 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
869 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
870 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
871 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
872 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
873 go_name = pfx; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
874 rest = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
875 result = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
876 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
877 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
878 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
879 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
880 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
881 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
882 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
883 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
|
884 const graphics_handle& h = graphics_handle (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
885 const graphics_handle& p = graphics_handle ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
886 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
887 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
888 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
889 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
890 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
891 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
892 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
893 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
894 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
895 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
896 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
897 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
898 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
899 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
900 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
901 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
902 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
903 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
904 go = new hggroup (h, p); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
905 else if (type.compare ("uimenu")) |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
906 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
|
907 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
|
908 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
|
909 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
|
910 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
|
911 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
|
912 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
|
913 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
|
914 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
|
915 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
|
916 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
|
917 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
|
918 go = new uitoggletool (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
919 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
920 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
921 |
6406 | 922 // --------------------------------------------------------------------- |
923 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
924 bool |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
925 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
|
926 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
927 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
928 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
929 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
930 // 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
|
931 if (id >= 0 && do_notify_toolkit) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
932 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
933 graphics_object go = gh_manager::get_object (parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
934 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
|
935 go.update (id); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
936 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
937 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
938 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
939 if (do_run && ! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
940 run_listeners (POSTSET); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
941 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
942 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
943 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
944 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
945 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
946 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
947 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
948 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
949 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
950 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
|
951 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
952 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
|
953 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
954 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
|
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 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
|
957 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
958 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
959 break; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
960 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
961 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
962 |
6705 | 963 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
|
964 : default_val (), possible_vals () |
6406 | 965 { |
6705 | 966 size_t beg = 0; |
967 size_t len = opt_string.length (); | |
968 bool done = len == 0; | |
6681 | 969 |
6705 | 970 while (! done) |
971 { | |
972 size_t end = opt_string.find ('|', beg); | |
6681 | 973 |
6705 | 974 if (end == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
975 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
976 end = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
977 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
978 } |
6681 | 979 |
6705 | 980 std::string t = opt_string.substr (beg, end-beg); |
6681 | 981 |
6705 | 982 // Might want more error checking here... |
983 if (t[0] == '{') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
984 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
985 t = t.substr (1, t.length () - 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
986 default_val = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
987 } |
6705 | 988 else if (beg == 0) // ensure default value |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
989 default_val = t; |
6681 | 990 |
6705 | 991 possible_vals.insert (t); |
6681 | 992 |
6705 | 993 beg = end + 1; |
994 } | |
995 } | |
6681 | 996 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
997 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
998 radio_values::values_as_string (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
999 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1000 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1001 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
|
1002 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1003 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1004 if (retval == "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1005 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1006 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1007 retval = "{" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1008 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1009 retval = *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1010 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1011 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1012 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1013 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1014 retval += " | {" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1015 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1016 retval += " | " + *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1017 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1018 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1019 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1020 retval = "[ " + retval + " ]"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1021 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1022 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1023 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1024 Cell |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1025 radio_values::values_as_cell (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1026 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1027 octave_idx_type i = 0; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1028 Cell retval (nelem (), 1); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1029 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
|
1030 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1031 retval(i++) = std::string (*it); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1032 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1033 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1034 |
6705 | 1035 bool |
6761 | 1036 color_values::str2rgb (std::string str) |
6681 | 1037 { |
6705 | 1038 double tmp_rgb[3] = {0, 0, 0}; |
1039 bool retval = true; | |
6761 | 1040 unsigned int len = str.length(); |
6681 | 1041 |
6925 | 1042 std::transform (str.begin (), str.end (), str.begin (), tolower); |
1043 | |
6761 | 1044 if (str.compare(0, len, "blue", 0, len) == 0) |
1045 tmp_rgb[2] = 1; | |
7869 | 1046 else if (str.compare(0, len, "black", 0, len) == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1047 || str.compare(0, len, "k", 0, len) == 0) |
6761 | 1048 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
1049 else if (str.compare(0, len, "red", 0, len) == 0) | |
1050 tmp_rgb[0] = 1; | |
1051 else if (str.compare(0, len, "green", 0, len) == 0) | |
1052 tmp_rgb[1] = 1; | |
1053 else if (str.compare(0, len, "yellow", 0, len) == 0) | |
1054 tmp_rgb[0] = tmp_rgb[1] = 1; | |
1055 else if (str.compare(0, len, "magenta", 0, len) == 0) | |
1056 tmp_rgb[0] = tmp_rgb[2] = 1; | |
1057 else if (str.compare(0, len, "cyan", 0, len) == 0) | |
1058 tmp_rgb[1] = tmp_rgb[2] = 1; | |
7869 | 1059 else if (str.compare(0, len, "white", 0, len) == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1060 || str.compare(0, len, "w", 0, len) == 0) |
6761 | 1061 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
|
1062 else |
6761 | 1063 retval = false; |
6406 | 1064 |
6705 | 1065 if (retval) |
1066 { | |
1067 for (int i = 0; i < 3; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1068 xrgb(i) = tmp_rgb[i]; |
6705 | 1069 } |
6563 | 1070 |
6705 | 1071 return retval; |
1072 } | |
6681 | 1073 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1074 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1075 color_property::do_set (const octave_value& val) |
6790 | 1076 { |
1077 if (val.is_string ()) | |
1078 { | |
1079 std::string s = val.string_value (); | |
1080 | |
1081 if (! s.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1082 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1083 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1084 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1085 if (radio_val.contains (s, match)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1086 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1087 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
|
1088 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1089 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
|
1090 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
|
1091 "%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
|
1092 "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
|
1093 match.c_str ()); |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1094 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1095 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1096 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1097 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1098 } |
6790 | 1099 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1100 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1101 color_values col (s); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1102 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1103 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1104 if (current_type != color_t || col != color_val) |
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 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1107 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1108 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1109 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1110 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1111 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1112 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
|
1113 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
|
1114 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1115 } |
6790 | 1116 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1117 error ("invalid value for color property \"%s\"", |
7363 | 1118 get_name ().c_str ()); |
6790 | 1119 } |
9311
868fbeb2e365
allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents:
9238
diff
changeset
|
1120 else if (val.is_numeric_type ()) |
6790 | 1121 { |
1122 Matrix m = val.matrix_value (); | |
1123 | |
1124 if (m.numel () == 3) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1125 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1126 color_values col (m (0), m (1), m(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1127 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1128 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1129 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1130 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1131 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1132 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1133 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1134 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1135 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1136 } |
6790 | 1137 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1138 error ("invalid value for color property \"%s\"", |
7363 | 1139 get_name ().c_str ()); |
6790 | 1140 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1141 else |
7363 | 1142 error ("invalid value for color property \"%s\"", |
1143 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1144 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1145 return false; |
6790 | 1146 } |
1147 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1148 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1149 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
|
1150 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1151 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1152 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1153 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
|
1154 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1155 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1156 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
|
1157 { |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1158 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
|
1159 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1160 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
|
1161 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
|
1162 "%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
|
1163 "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
|
1164 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
|
1165 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1166 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1167 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1168 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1169 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1170 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1171 error ("invalid value for double_radio property \"%s\"", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1172 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
|
1173 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1174 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
|
1175 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1176 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1177 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1178 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
|
1179 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1180 dval = new_dval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1181 current_type = double_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1182 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1183 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1184 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1185 else |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1186 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
|
1187 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1188 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1189 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1190 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1191 |
7363 | 1192 bool |
1193 array_property::validate (const octave_value& v) | |
1194 { | |
7364 | 1195 bool xok = false; |
7363 | 1196 |
8333 | 1197 // FIXME -- should we always support []? |
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
|
1198 if (v.is_empty () && v.is_numeric_type ()) |
7363 | 1199 return true; |
1200 | |
1201 // check value type | |
1202 if (type_constraints.size () > 0) | |
1203 { | |
1204 for (std::list<std::string>::const_iterator it = type_constraints.begin (); | |
7364 | 1205 ! xok && it != type_constraints.end (); ++it) |
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
|
1206 if ((*it) == v.class_name ()) |
7364 | 1207 xok = true; |
7363 | 1208 } |
1209 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
|
1210 xok = v.is_numeric_type (); |
7363 | 1211 |
7364 | 1212 if (xok) |
7363 | 1213 { |
1214 dim_vector vdims = v.dims (); | |
1215 int vlen = vdims.length (); | |
1216 | |
7364 | 1217 xok = false; |
7363 | 1218 |
1219 // check value size | |
1220 if (size_constraints.size () > 0) | |
1221 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); | |
7364 | 1222 ! xok && it != size_constraints.end (); ++it) |
7363 | 1223 { |
1224 dim_vector itdims = (*it); | |
1225 | |
1226 if (itdims.length () == vlen) | |
1227 { | |
7364 | 1228 xok = true; |
7363 | 1229 |
7364 | 1230 for (int i = 0; xok && i < vlen; i++) |
7363 | 1231 if (itdims(i) >= 0 && itdims(i) != vdims(i)) |
7364 | 1232 xok = false; |
7363 | 1233 } |
1234 } | |
1235 else | |
1236 return true; | |
1237 } | |
1238 | |
7364 | 1239 return xok; |
7363 | 1240 } |
1241 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1242 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1243 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1244 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1245 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1246 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1247 if (data.dims () == v.dims ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1248 { |
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
|
1249 |
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
|
1250 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1251 { \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1252 if (data.numel () == 1) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1253 return data.F ## scalar_value () == \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1254 v.F ## scalar_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1255 else \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1256 { \ |
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
|
1257 /* 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
|
1258 /* that are converted, to not be deallocated early */ \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1259 const A m1 = data.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1260 const T* d1 = m1.data (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1261 const A m2 = v.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1262 const T* d2 = m2.data ();\ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1263 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1264 bool flag = true; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1265 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1266 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
|
1267 if (d1[i] != d2[i]) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1268 flag = false; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1269 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1270 return flag; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1271 } \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1272 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1273 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1274 if (data.is_double_type() || data.is_bool_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1275 CHECK_ARRAY_EQUAL (double, , NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1276 else if (data.is_single_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1277 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1278 else if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1279 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1280 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1281 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1282 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1283 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1284 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1285 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1286 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1287 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1288 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1289 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1290 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1291 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1292 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1293 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1294 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1295 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1296 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1297 return false; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1298 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1299 |
7363 | 1300 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
|
1301 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
|
1302 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1303 xmin = xminp = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1304 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
|
1305 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1306 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
|
1307 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1308 if (data.is_integer_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1309 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1310 if (data.is_int8_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1311 get_array_limits (data.int8_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1312 else if (data.is_uint8_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1313 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1314 else if (data.is_int16_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1315 get_array_limits (data.int16_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1316 else if (data.is_uint16_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1317 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1318 else if (data.is_int32_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1319 get_array_limits (data.int32_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1320 else if (data.is_uint32_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1321 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1322 else if (data.is_int64_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1323 get_array_limits (data.int64_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1324 else if (data.is_uint64_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1325 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1326 } |
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
|
1327 else |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1328 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
|
1329 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1330 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1331 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1332 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1333 handle_property::do_set (const octave_value& v) |
7363 | 1334 { |
1335 double dv = v.double_value (); | |
1336 | |
1337 if (! error_state) | |
1338 { | |
1339 graphics_handle gh = gh_manager::lookup (dv); | |
1340 | |
1341 if (xisnan (gh.value ()) || gh.ok ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1342 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1343 if (current_val != gh) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1344 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1345 current_val = gh; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1346 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1347 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1348 } |
7363 | 1349 else |
1350 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
|
1351 dv, get_name ().c_str ()); |
7363 | 1352 } |
1353 else | |
1354 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
|
1355 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1356 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1357 return false; |
7363 | 1358 } |
1359 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1360 Matrix |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1361 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
|
1362 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1363 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
|
1364 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
|
1365 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1366 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
|
1367 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1368 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
|
1369 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
|
1370 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1371 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
|
1372 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1373 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
|
1374 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
|
1375 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1376 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
|
1377 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1378 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
|
1379 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1380 if (! return_hidden) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1381 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1382 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1383 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
|
1384 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1385 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1386 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1387 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
|
1388 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1389 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1390 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1391 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
|
1392 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
|
1393 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1394 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1395 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1396 return retval; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1397 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1398 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1399 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1400 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
|
1401 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1402 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
|
1403 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
|
1404 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1405 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
|
1406 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1407 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
|
1408 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
|
1409 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1410 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1411 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1412 if (clear) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1413 children_list.clear (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1414 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1415 |
7363 | 1416 bool |
7367 | 1417 callback_property::validate (const octave_value& v) const |
7363 | 1418 { |
7367 | 1419 // case 1: function handle |
1420 // case 2: cell array with first element being a function handle | |
1421 // case 3: string corresponding to known function name | |
1422 // case 4: evaluatable string | |
1423 // case 5: empty matrix | |
1424 | |
1425 if (v.is_function_handle ()) | |
1426 return true; | |
1427 else if (v.is_string ()) | |
1428 // complete validation will be done at execution-time | |
1429 return true; | |
1430 else if (v.is_cell () && v.length () > 0 | |
1431 && (v.rows() == 1 || v.columns () == 1) | |
1432 && v.cell_value ()(0).is_function_handle ()) | |
1433 return true; | |
1434 else if (v.is_empty ()) | |
1435 return true; | |
1436 | |
1437 return false; | |
7363 | 1438 } |
1439 | |
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
|
1440 // 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
|
1441 // 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
|
1442 // 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
|
1443 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
|
1444 |
7363 | 1445 void |
7367 | 1446 callback_property::execute (const octave_value& data) const |
7363 | 1447 { |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1448 unwind_protect frame; |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1449 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1450 // 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
|
1451 // 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
|
1452 // callback routines. |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1453 frame.protect_var (executing); |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1454 |
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
|
1455 // 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
|
1456 // 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
|
1457 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
|
1458 |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1459 if (! executing) |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1460 { |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1461 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
|
1462 executing_callback = true; |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1463 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1464 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
|
1465 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
|
1466 } |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1467 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1468 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1469 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1470 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1471 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
|
1472 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1473 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1474 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
|
1475 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
|
1476 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1477 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1478 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1479 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1480 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1481 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
|
1482 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1483 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1484 retval = property (new string_property (name, h, val)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1485 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1486 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1487 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1488 octave_value val = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1489 (args.length () > 0 ? args(0) : octave_value (Matrix ())); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1490 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1491 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1492 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1493 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1494 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1495 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1496 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1497 std::string vals = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1498 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1499 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1500 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1501 retval = property (new radio_property (name, h, vals)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1502 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1503 if (args.length () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1504 retval.set (args(1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1505 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1506 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1507 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
|
1508 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1509 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1510 error ("addproperty: missing possible values for radio property"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1511 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1512 else if (type.compare ("double")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1513 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1514 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
|
1515 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1516 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1517 retval = property (new double_property (name, h, d)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1518 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1519 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1520 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1521 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
|
1522 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1523 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1524 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1525 graphics_handle gh (hh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1526 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1527 retval = property (new handle_property (name, h, gh)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1528 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1529 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1530 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1531 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1532 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1533 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1534 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1535 retval.set (args(0)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1536 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1537 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1538 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1539 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1540 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1541 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1542 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1543 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1544 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1545 // FIXME -- additional argument could define constraints, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1546 // but is this really useful? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1547 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1548 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1549 else if (type.compare ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1550 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1551 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1552 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1553 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1554 if (args.length () > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1555 rv = radio_values (args(1).string_value ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1556 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1557 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1558 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1559 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
|
1560 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1561 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1562 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1563 if (args.length () > 0 && ! args(0).is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1564 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1565 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1566 retval.set (rv.default_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1567 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1568 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1569 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1570 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1571 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1572 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1573 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1574 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
|
1575 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1576 graphics_object go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1577 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1578 std::map<caseless_str, graphics_object>::const_iterator it = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1579 dprop_obj_map.find (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1580 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1581 if (it == dprop_obj_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1582 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1583 base_graphics_object *bgo = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1584 make_graphics_object_from_type (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1585 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1586 if (bgo) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1587 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1588 go = graphics_object (bgo); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1589 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1590 dprop_obj_map[go_name] = go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1591 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1592 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1593 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1594 go = it->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1595 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1596 if (go.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1597 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1598 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
|
1599 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1600 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1601 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1602 retval = prop.clone (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1603 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1604 retval.set_parent (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1605 retval.set_name (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1606 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1607 if (args.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1608 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1609 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1610 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1611 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1612 error ("addproperty: invalid object type (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1613 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1614 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1615 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1616 error ("addproperty: unsupported type for dynamic property (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1617 type.c_str ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1618 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1619 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1620 return retval; |
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 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1623 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1624 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
|
1625 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1626 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
|
1627 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1628 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1629 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1630 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
|
1631 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1632 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
|
1633 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
|
1634 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1635 go.finalize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1636 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1637 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1638 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1639 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1640 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
|
1641 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1642 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
|
1643 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1644 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1645 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1646 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
|
1647 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1648 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1649 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1650 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
|
1651 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
|
1652 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1653 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1654 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1655 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1656 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
|
1657 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1658 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1659 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
|
1660 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1661 toolkit = b; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1662 __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
|
1663 __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
|
1664 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1665 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1666 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
|
1667 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1668 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1669 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1670 |
7363 | 1671 // --------------------------------------------------------------------- |
6681 | 1672 |
6705 | 1673 void |
7189 | 1674 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1675 { |
6705 | 1676 size_t offset = 0; |
6681 | 1677 |
6705 | 1678 size_t len = name.length (); |
6681 | 1679 |
6705 | 1680 if (len > 4) |
1681 { | |
7189 | 1682 caseless_str pfx = name.substr (0, 4); |
6681 | 1683 |
6705 | 1684 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1685 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1686 offset = 4; |
6705 | 1687 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1688 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1689 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1690 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1691 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1692 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1693 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1694 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1695 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1696 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1697 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1698 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1699 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1700 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1701 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1702 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1703 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
|
1704 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1705 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
|
1706 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
|
1707 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1708 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
|
1709 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1710 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1711 || 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
|
1712 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1713 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1714 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1715 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
|
1716 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1717 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1718 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1719 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1720 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1721 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
|
1722 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1723 if (pfx.compare ("uitoogletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1724 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1725 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1726 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1727 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
|
1728 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1729 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1730 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1731 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1732 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1733 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1734 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1735 } |
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 } |
6681 | 1738 |
6705 | 1739 if (offset > 0) |
10315
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 // FIXME -- should we validate property names and values here? |
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 std::string pname = name.substr (offset); |
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 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1746 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
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 bool has_property = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1749 if (pfx == "axes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1750 has_property = axes::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1751 else if (pfx == "line") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1752 has_property = line::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1753 else if (pfx == "text") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1754 has_property = text::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1755 else if (pfx == "image") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1756 has_property = image::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1757 else if (pfx == "patch") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1758 has_property = patch::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1759 else if (pfx == "figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1760 has_property = figure::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1761 else if (pfx == "surface") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1762 has_property = surface::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1763 else if (pfx == "hggroup") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1764 has_property = hggroup::properties::has_core_property (pname); |
11283 | 1765 else if (pfx == "uimenu") |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1766 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
|
1767 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
|
1768 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
|
1769 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
|
1770 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
|
1771 else if (pfx == "uicontextmenu") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1772 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
|
1773 else if (pfx == "uitoolbar") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1774 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
|
1775 else if (pfx == "uipushtool") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1776 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
|
1777 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1778 if (has_property) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1779 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1780 bool remove = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1781 if (val.is_string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1782 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1783 caseless_str tval = val.string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1784 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1785 remove = tval.compare ("remove"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1786 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1787 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1788 pval_map_type& pval_map = plist_map[pfx]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1789 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1790 if (remove) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1791 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1792 pval_map_iterator p = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1793 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1794 if (p != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1795 pval_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1796 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1797 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1798 pval_map[pname] = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1799 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1800 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1801 error ("invalid %s property `%s'", pfx.c_str (), pname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1802 } |
6705 | 1803 } |
6406 | 1804 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
1805 if (! error_state && offset == 0) |
6705 | 1806 error ("invalid default property specification"); |
1807 } | |
6406 | 1808 |
6705 | 1809 octave_value |
7189 | 1810 property_list::lookup (const caseless_str& name) const |
6705 | 1811 { |
1812 octave_value retval; | |
6406 | 1813 |
6705 | 1814 size_t offset = 0; |
6406 | 1815 |
6705 | 1816 size_t len = name.length (); |
6406 | 1817 |
6705 | 1818 if (len > 4) |
1819 { | |
7189 | 1820 caseless_str pfx = name.substr (0, 4); |
6406 | 1821 |
6705 | 1822 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1823 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1824 offset = 4; |
6705 | 1825 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1826 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1827 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1828 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1829 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1830 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1831 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1832 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1833 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1834 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1835 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1836 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1837 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1838 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1839 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1840 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1841 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
|
1842 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1843 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
|
1844 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
|
1845 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1846 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
|
1847 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1848 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1849 || 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
|
1850 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1851 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1852 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1853 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
|
1854 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1855 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1856 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1857 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1858 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1859 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
|
1860 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1861 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1862 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1863 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1864 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1865 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
|
1866 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1867 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1868 offset = 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 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1871 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1872 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1873 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1874 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1875 } |
6406 | 1876 |
6705 | 1877 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1878 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1879 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1880 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1881 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1882 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
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 plist_map_const_iterator p = find (pfx); |
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 if (p != end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1887 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1888 const pval_map_type& pval_map = p->second; |
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 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
|
1891 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1892 if (q != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1893 retval = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1894 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1895 } |
6705 | 1896 } |
6406 | 1897 |
6705 | 1898 return retval; |
1899 } | |
6406 | 1900 |
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
|
1901 octave_scalar_map |
6705 | 1902 property_list::as_struct (const std::string& prefix_arg) const |
1903 { | |
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
|
1904 octave_scalar_map m; |
6406 | 1905 |
6705 | 1906 for (plist_map_const_iterator p = begin (); p != end (); p++) |
1907 { | |
1908 std::string prefix = prefix_arg + p->first; | |
6406 | 1909 |
6705 | 1910 const pval_map_type pval_map = p->second; |
6406 | 1911 |
6705 | 1912 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
|
1913 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1914 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1915 m.assign (prefix + q->first, q->second); |
6705 | 1916 } |
6406 | 1917 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1918 return m; |
6705 | 1919 } |
6432 | 1920 |
6874 | 1921 graphics_handle::graphics_handle (const octave_value& a) |
1922 : val (octave_NaN) | |
1923 { | |
1924 if (a.is_empty ()) | |
1925 /* do nothing */; | |
1926 else | |
1927 { | |
1928 double tval = a.double_value (); | |
1929 | |
1930 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1931 val = tval; |
6874 | 1932 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1933 error ("invalid graphics handle"); |
6874 | 1934 } |
1935 } | |
1936 | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1937 // 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
|
1938 |
6705 | 1939 void |
1940 graphics_object::set (const octave_value_list& args) | |
1941 { | |
1942 int nargin = args.length (); | |
6406 | 1943 |
6705 | 1944 if (nargin == 0) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1945 error ("graphics_object::set: Nothing to set"); |
6705 | 1946 else if (nargin % 2 == 0) |
1947 { | |
1948 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
|
1949 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1950 caseless_str name = args(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1951 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1952 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1953 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1954 octave_value val = args(i+1); |
6406 | 1955 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1956 set_value_or_default (name, val); |
6406 | 1957 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1958 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1959 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1960 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1961 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1962 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
|
1963 } |
6705 | 1964 } |
1965 else | |
1966 error ("set: invalid number of arguments"); | |
1967 } | |
6406 | 1968 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1969 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1970 %!# test set with name, value pairs |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1971 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1972 %! set(gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1973 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1974 %! set (h, "linewidth", 10, "marker", "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1975 %! assert (get (h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1976 %! assert (get (h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1977 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1978 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1979 // 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
|
1980 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1981 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
|
1982 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
|
1983 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1984 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
|
1985 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1986 error("set: number of names must match number of value columns (%d != %d)", |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1987 names.numel (), values.columns ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1988 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1989 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1990 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
|
1991 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1992 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
|
1993 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1994 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
|
1995 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
|
1996 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1997 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
|
1998 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1999 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2000 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2001 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2002 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2003 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2004 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2005 %!# test set with cell array arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2006 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2007 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2008 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2009 %! set (h, {"linewidth", "marker"}, {10, "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2010 %! assert (get(h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2011 %! assert (get(h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2012 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2013 %!# test set with multiple handles and cell array arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2014 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2015 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2016 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2017 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2018 %! assert (get (h, "linewidth"), {10; 5}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2019 %! assert (get (h, "marker"), {"x"; "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2020 %! set (h, {"linewidth", "marker"}, {10, "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2021 %! assert (get (h, "linewidth"), {10; 10}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2022 %! assert (get (h, "marker"), {"x"; "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2023 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2024 %!error <set: number of graphics handles must match number of value rows> |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2025 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2026 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2027 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2028 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2029 %!error <set: number of names must match number of value columns> |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2030 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2031 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2032 %! set (h, {"linewidth"}, {10, "x"; 5, "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2033 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2034 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2035 // 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
|
2036 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
|
2037 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
|
2038 { |
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
|
2039 for (octave_map::const_iterator p = m.begin (); |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2040 p != m.end (); p++) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2041 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2042 caseless_str name = m.key (p); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2043 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2044 octave_value val = octave_value (m.contents (p).elem (m.numel () - 1)); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2045 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2046 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
|
2047 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2048 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2049 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2050 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2051 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2052 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2053 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2054 %!# test set with struct arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2055 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2056 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2057 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2058 %! set (h, struct ("linewidth", 10, "marker", "x")); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2059 %! assert (get (h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2060 %! assert (get (h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2061 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2062 %! set (h, struct ("linewidth", {5, 10})); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2063 %! assert (get(h, "linewidth"), {10; 10}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2064 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2065 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2066 // 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
|
2067 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2068 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2069 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
|
2070 const octave_value& val) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2071 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2072 if (val.is_string ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2073 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2074 caseless_str tval = val.string_value (); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2075 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2076 octave_value default_val; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2077 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2078 if (tval.compare ("default")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2079 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2080 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
|
2081 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2082 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2083 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2084 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2085 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
|
2086 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2087 else if (tval.compare ("factory")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2088 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2089 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
|
2090 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2091 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2092 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2093 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2094 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
|
2095 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2096 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2097 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2098 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2099 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2100 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2101 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2102 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2103 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2104 %!# test setting of default values |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2105 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2106 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2107 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2108 %! set (0, "defaultlinelinewidth", 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2109 %! set (h, "linewidth", "default"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2110 %! assert (get (h, "linewidth"), 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2111 %! set (h, "linewidth", "factory"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2112 %! assert (get (h, "linewidth"), 0.5); |
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 |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2115 static double |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2116 make_handle_fraction (void) |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2117 { |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2118 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
|
2119 |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2120 return (rand () + 1.0) / maxrand; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2121 } |
6406 | 2122 |
6705 | 2123 graphics_handle |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2124 gh_manager::do_get_handle (bool integer_figure_handle) |
6705 | 2125 { |
2126 graphics_handle retval; | |
6406 | 2127 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
2128 if (integer_figure_handle) |
6705 | 2129 { |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2130 // 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
|
2131 // figure number. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2132 |
6705 | 2133 // We always want the lowest unused figure number. |
6406 | 2134 |
6705 | 2135 retval = 1; |
6425 | 2136 |
6705 | 2137 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
|
2138 retval++; |
6705 | 2139 } |
2140 else | |
2141 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2142 // 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
|
2143 // 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
|
2144 // 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
|
2145 // time. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2146 |
6705 | 2147 free_list_iterator p = handle_free_list.begin (); |
6406 | 2148 |
6705 | 2149 if (p != handle_free_list.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2150 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2151 retval = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2152 handle_free_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2153 } |
6705 | 2154 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2155 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2156 retval = graphics_handle (next_handle); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2157 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
2158 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
|
2159 } |
6705 | 2160 } |
6406 | 2161 |
6705 | 2162 return retval; |
2163 } | |
6406 | 2164 |
6705 | 2165 void |
2166 gh_manager::do_free (const graphics_handle& h) | |
2167 { | |
7056 | 2168 if (h.ok ()) |
6705 | 2169 { |
6874 | 2170 if (h.value () != 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2171 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2172 iterator p = handle_map.find (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2173 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2174 if (p != handle_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2175 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2176 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
|
2177 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2178 bp.set_beingdeleted (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2179 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2180 bp.delete_children (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2181 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2182 octave_value val = bp.get_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2183 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2184 bp.execute_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2185 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2186 // 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
|
2187 p->second.finalize (); |
8208 | 2188 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2189 // 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
|
2190 // 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
|
2191 // unknown graphics toolkit. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2192 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2193 // Graphics handles for non-figure objects are negative |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2194 // integers plus some random fractional part. To avoid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2195 // 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
|
2196 // 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
|
2197 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2198 handle_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2199 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2200 if (h.value () < 0) |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
2201 handle_free_list.insert (std::ceil (h.value ()) - make_handle_fraction ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2202 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2203 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2204 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
|
2205 } |
6705 | 2206 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2207 error ("graphics_handle::free: can't delete root figure"); |
6705 | 2208 } |
2209 } | |
6406 | 2210 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2211 void |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2212 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
|
2213 const graphics_handle& new_gh) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2214 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2215 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
|
2216 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2217 if (p != handle_map.end ()) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2218 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2219 graphics_object go = p->second; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2220 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2221 handle_map.erase (p); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2222 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2223 handle_map[new_gh] = go; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2224 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2225 if (old_gh.value () < 0) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2226 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
|
2227 - make_handle_fraction ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2228 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2229 else |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2230 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
|
2231 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2232 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
|
2233 q != figure_list.end (); q++) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2234 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2235 if (*q == old_gh) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2236 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2237 *q = new_gh; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2238 break; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2239 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2240 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2241 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2242 |
6406 | 2243 gh_manager *gh_manager::instance = 0; |
2244 | |
2245 static void | |
7189 | 2246 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 2247 const octave_value& val) |
2248 { | |
2249 graphics_object obj = gh_manager::get_object (h); | |
2250 obj.set (name, val); | |
2251 } | |
2252 | |
2253 static void | |
2254 xset (const graphics_handle& h, const octave_value_list& args) | |
2255 { | |
2256 if (args.length () > 0) | |
2257 { | |
2258 graphics_object obj = gh_manager::get_object (h); | |
2259 obj.set (args); | |
2260 } | |
2261 } | |
2262 | |
2263 static octave_value | |
7189 | 2264 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 2265 { |
2266 graphics_object obj = gh_manager::get_object (h); | |
2267 return obj.get (name); | |
2268 } | |
2269 | |
2270 static graphics_handle | |
2271 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
|
2272 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
|
2273 bool adopt = true) |
6406 | 2274 { |
2275 graphics_handle h = octave_NaN; | |
2276 | |
2277 double val = ov.double_value (); | |
2278 | |
2279 if (! error_state) | |
2280 { | |
2281 h = gh_manager::lookup (val); | |
2282 | |
7056 | 2283 if (h.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2284 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2285 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
|
2286 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2287 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2288 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2289 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
|
2290 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2291 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2292 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2293 if (adopt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2294 obj.set ("parent", new_parent.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2295 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2296 obj.reparent (new_parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2297 } |
6406 | 2298 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2299 error ("%s: invalid graphics handle (= %g) for %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2300 who.c_str (), val, property.c_str ()); |
6406 | 2301 } |
2302 else | |
2303 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
|
2304 who.c_str (), property.c_str ()); |
6406 | 2305 |
2306 return h; | |
2307 } | |
2308 | |
2309 // This function is NOT equivalent to the scripting language function gcf. | |
2310 graphics_handle | |
2311 gcf (void) | |
2312 { | |
2313 octave_value val = xget (0, "currentfigure"); | |
2314 | |
2315 return val.is_empty () ? octave_NaN : val.double_value (); | |
2316 } | |
2317 | |
2318 // This function is NOT equivalent to the scripting language function gca. | |
2319 graphics_handle | |
2320 gca (void) | |
2321 { | |
2322 octave_value val = xget (gcf (), "currentaxes"); | |
2323 | |
2324 return val.is_empty () ? octave_NaN : val.double_value (); | |
2325 } | |
2326 | |
2327 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
|
2328 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
|
2329 { |
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
|
2330 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
|
2331 { |
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
|
2332 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
|
2333 |
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
|
2334 // 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
|
2335 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
|
2336 { |
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
|
2337 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
|
2338 |
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
|
2339 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
|
2340 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
|
2341 |
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
|
2342 // 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
|
2343 // 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
|
2344 // 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
|
2345 // 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
|
2346 |
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
|
2347 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
|
2348 |
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
|
2349 // 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
|
2350 // 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
|
2351 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
|
2352 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
|
2353 |
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
|
2354 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
|
2355 } |
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
|
2356 } |
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
|
2357 } |
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
|
2358 |
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
|
2359 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
|
2360 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
|
2361 { |
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
|
2362 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
|
2363 } |
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
|
2364 |
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
|
2365 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
|
2366 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
|
2367 { |
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
|
2368 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
|
2369 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
|
2370 } |
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
|
2371 |
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
|
2372 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
|
2373 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
|
2374 { |
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
|
2375 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
|
2376 |
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
|
2377 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
|
2378 } |
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
|
2379 |
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
|
2380 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
|
2381 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
|
2382 { |
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
|
2383 // 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
|
2384 // 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
|
2385 |
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
|
2386 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
|
2387 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
|
2388 |
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
|
2389 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
|
2390 } |
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
|
2391 |
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
|
2392 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
|
2393 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
|
2394 { |
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
|
2395 // FIXME -- should we process or discard pending events? |
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
|
2396 |
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
|
2397 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
|
2398 |
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
|
2399 // 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
|
2400 // 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
|
2401 |
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
|
2402 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
|
2403 |
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
|
2404 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
|
2405 { |
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
|
2406 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
|
2407 |
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
|
2408 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
|
2409 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
|
2410 } |
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
|
2411 |
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
|
2412 // 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
|
2413 |
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
|
2414 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
|
2415 |
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
|
2416 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
|
2417 { |
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
|
2418 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
|
2419 |
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
|
2420 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
|
2421 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
|
2422 } |
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
|
2423 |
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
|
2424 // 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
|
2425 |
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
|
2426 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
|
2427 |
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
|
2428 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
|
2429 |
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
|
2430 // 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
|
2431 |
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
|
2432 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
|
2433 } |
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
|
2434 |
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
|
2435 static void |
6406 | 2436 adopt (const graphics_handle& p, const graphics_handle& h) |
2437 { | |
2438 graphics_object parent_obj = gh_manager::get_object (p); | |
2439 parent_obj.adopt (h); | |
2440 } | |
2441 | |
2442 static bool | |
7056 | 2443 is_handle (const graphics_handle& h) |
2444 { | |
2445 return h.ok (); | |
2446 } | |
2447 | |
2448 static bool | |
6406 | 2449 is_handle (double val) |
2450 { | |
6874 | 2451 graphics_handle h = gh_manager::lookup (val); |
2452 | |
2453 return h.ok (); | |
6406 | 2454 } |
2455 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2456 static octave_value |
6406 | 2457 is_handle (const octave_value& val) |
2458 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2459 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2460 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2461 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
|
2462 retval = true; |
12587
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2463 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
|
2464 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2465 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
|
2466 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2467 if (! error_state) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2468 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2469 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
|
2470 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2471 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
|
2472 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
|
2473 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2474 retval = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2475 } |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2476 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2477 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2478 return retval; |
6406 | 2479 } |
2480 | |
2481 static bool | |
2482 is_figure (double val) | |
2483 { | |
2484 graphics_object obj = gh_manager::get_object (val); | |
2485 | |
2486 return obj && obj.isa ("figure"); | |
2487 } | |
2488 | |
7370 | 2489 static void |
2490 xcreatefcn (const graphics_handle& h) | |
2491 { | |
2492 graphics_object obj = gh_manager::get_object (h); | |
2493 obj.get_properties ().execute_createfcn (); | |
2494 } | |
2495 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2496 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2497 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
|
2498 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2499 graphics_object go = gh_manager::get_object (h); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
2500 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2501 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2502 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2503 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2504 |
6406 | 2505 // --------------------------------------------------------------------- |
2506 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2507 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2508 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
|
2509 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2510 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2511 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2512 update (go, id); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2513 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2514 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2515 bool |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2516 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
|
2517 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2518 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2519 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2520 return initialize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2521 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2522 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2523 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2524 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
|
2525 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2526 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2527 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2528 finalize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2529 } |
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
|
2530 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2531 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2532 |
6705 | 2533 void |
2534 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
|
2535 property_list& defaults) |
6406 | 2536 { |
6705 | 2537 std::string go_name = graphics_object_name (); |
6406 | 2538 |
6705 | 2539 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 2540 |
6705 | 2541 if (p != defaults.end ()) |
2542 { | |
2543 const property_list::pval_map_type pval_map = p->second; | |
6406 | 2544 |
6705 | 2545 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
|
2546 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2547 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2548 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2549 std::string pname = q->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2550 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2551 obj.set (pname, q->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2552 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2553 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2554 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2555 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
|
2556 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2557 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2558 } |
6705 | 2559 } |
2560 } | |
6406 | 2561 |
7363 | 2562 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2563 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 2564 { |
2565 octave_value retval; | |
2566 | |
8090 | 2567 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2568 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2569 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2570 retval = it->second.get (); |
7363 | 2571 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2572 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 2573 |
2574 return retval; | |
2575 } | |
2576 | |
2577 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2578 base_properties::get_dynamic (bool all) const |
7363 | 2579 { |
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
|
2580 octave_scalar_map m; |
7363 | 2581 |
8090 | 2582 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin (); |
7363 | 2583 it != all_props.end (); ++it) |
7379 | 2584 if (all || ! it->second.is_hidden ()) |
2585 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 2586 |
2587 return m; | |
2588 } | |
2589 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2590 std::set<std::string> |
9972 | 2591 base_properties::dynamic_property_names (void) const |
2592 { | |
2593 return dynamic_properties; | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2594 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2595 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2596 bool |
9972 | 2597 base_properties::has_dynamic_property (const std::string& pname) |
2598 { | |
2599 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
|
2600 |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2601 if (dynprops.find (pname) != dynprops.end ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2602 return true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2603 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
2604 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
|
2605 } |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2606 |
7363 | 2607 void |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2608 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
|
2609 const octave_value& val) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2610 { |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2611 std::map<caseless_str, property, cmp_caseless_str>::iterator it = all_props.find (pname); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2612 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2613 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2614 it->second.set (val); |
7363 | 2615 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2616 error ("set: unknown property \"%s\"", pname.c_str ()); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2617 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2618 if (! error_state) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2619 { |
9972 | 2620 dynamic_properties.insert (pname); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2621 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2622 mark_modified (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2623 } |
7363 | 2624 } |
2625 | |
2626 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2627 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 2628 { |
8090 | 2629 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2630 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2631 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2632 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2633 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2634 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2635 } |
7363 | 2636 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2637 return it->second; |
7363 | 2638 } |
2639 | |
6705 | 2640 void |
6836 | 2641 base_properties::set_parent (const octave_value& val) |
6705 | 2642 { |
2643 double tmp = val.double_value (); | |
6406 | 2644 |
6705 | 2645 graphics_handle new_parent = octave_NaN; |
6406 | 2646 |
6705 | 2647 if (! error_state) |
2648 { | |
2649 new_parent = gh_manager::lookup (tmp); | |
6406 | 2650 |
7056 | 2651 if (new_parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2652 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2653 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2654 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2655 parent_obj.remove_child (__myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2656 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2657 parent = new_parent.as_octave_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2658 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2659 ::adopt (parent.handle_value (), __myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2660 } |
6705 | 2661 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2662 error ("set: invalid graphics handle (= %g) for parent", tmp); |
6705 | 2663 } |
2664 else | |
2665 error ("set: expecting parent to be a graphics handle"); | |
2666 } | |
6432 | 2667 |
6705 | 2668 void |
6836 | 2669 base_properties::mark_modified (void) |
2670 { | |
7363 | 2671 __modified__ = "on"; |
2672 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 2673 if (parent_obj) |
2674 parent_obj.mark_modified (); | |
6836 | 2675 } |
2676 | |
2677 void | |
2678 base_properties::override_defaults (base_graphics_object& obj) | |
2679 { | |
7363 | 2680 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
|
2681 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2682 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2683 parent_obj.override_defaults (obj); |
6836 | 2684 } |
2685 | |
2686 void | |
7214 | 2687 base_properties::update_axis_limits (const std::string& axis_type) const |
2688 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2689 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
|
2690 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2691 if (obj) |
7214 | 2692 obj.update_axis_limits (axis_type); |
2693 } | |
2694 | |
2695 void | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2696 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
|
2697 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
|
2698 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2699 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
|
2700 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2701 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2702 obj.update_axis_limits (axis_type, h); |
6836 | 2703 } |
2704 | |
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
|
2705 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
|
2706 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
|
2707 { |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2708 return (handlevisibility.is ("on") |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
2709 || (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
|
2710 } |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2711 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2712 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2713 base_properties::get_toolkit (void) const |
7419 | 2714 { |
2715 graphics_object go = gh_manager::get_object (get_parent ()); | |
2716 | |
2717 if (go) | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2718 return go.get_toolkit (); |
7419 | 2719 else |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2720 return graphics_toolkit (); |
7419 | 2721 } |
2722 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2723 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2724 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
|
2725 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2726 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
|
2727 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2728 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
|
2729 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2730 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
|
2731 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2732 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2733 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
|
2734 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2735 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2736 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2737 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2738 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
|
2739 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2740 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
|
2741 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2742 if (parent_obj.valid_object ()) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2743 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
|
2744 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2745 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2746 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2747 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
|
2748 listener_mode mode) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2749 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2750 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2751 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2752 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2753 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2754 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2755 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2756 void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2757 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
|
2758 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
|
2759 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2760 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
|
2761 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2762 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
|
2763 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
|
2764 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2765 |
7363 | 2766 // --------------------------------------------------------------------- |
2767 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2768 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2769 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
|
2770 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2771 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
|
2772 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2773 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
|
2774 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2775 if (parent_obj) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2776 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
|
2777 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2778 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2779 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
|
2780 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2781 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2782 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2783 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
|
2784 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
|
2785 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2786 if (valid_object ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2787 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2788 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
|
2789 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2790 if (parent_obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2791 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
|
2792 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2793 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2794 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
|
2795 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2796 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2797 void |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2798 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
|
2799 { |
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
|
2800 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
|
2801 |
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
|
2802 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
|
2803 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2804 // FIXME -- there has to be a better way. I think we want to |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2805 // 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
|
2806 // 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
|
2807 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2808 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2809 |
13849
b4b8e525dee0
Stop debug_on_error triggering for a new plot (bug #32655)
Rik <octave@nomad.inbox5.com>
parents:
13830
diff
changeset
|
2810 frame.protect_var (error_state); |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2811 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
|
2812 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
|
2813 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
|
2814 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2815 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
|
2816 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
|
2817 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
|
2818 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2819 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
|
2820 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2821 if (! error_state && p.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2822 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
|
2823 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2824 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2825 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2826 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2827 base_graphics_object::values_as_string (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2828 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2829 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2830 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2831 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2832 { |
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
|
2833 octave_map m = get ().map_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2834 |
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
|
2835 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
|
2836 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2837 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2838 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2839 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2840 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2841 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2842 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2843 retval += "\n\t" + std::string (pa->first) + ": "; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2844 if (p.is_radio ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2845 retval += p.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2846 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2847 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2848 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2849 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2850 retval += "\n"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2851 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2852 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2853 error ("base_graphics_object::values_as_string: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2854 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2855 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2856 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2857 |
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
|
2858 octave_scalar_map |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2859 base_graphics_object::values_as_struct (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2860 { |
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
|
2861 octave_scalar_map retval; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2862 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2863 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2864 { |
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
|
2865 octave_scalar_map m = get ().scalar_map_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2866 |
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
|
2867 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
|
2868 pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2869 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2870 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2871 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2872 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2873 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2874 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2875 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2876 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
|
2877 retval.assign (p.get_name (), p.values_as_cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2878 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
|
2879 retval.assign (p.get_name (), Cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2880 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2881 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2882 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2883 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2884 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2885 error ("base_graphics_object::values_as_struct: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2886 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2887 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2888 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2889 |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2890 graphics_object |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2891 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
|
2892 { |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2893 if (valid_object ()) |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2894 { |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2895 if (isa (obj_type)) |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2896 return *this; |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2897 else |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2898 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
|
2899 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2900 else |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2901 return graphics_object (); |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2902 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2903 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2904 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2905 |
7363 | 2906 #include "graphics-props.cc" |
2907 | |
2908 // --------------------------------------------------------------------- | |
2909 | |
6836 | 2910 void |
7363 | 2911 root_figure::properties::set_currentfigure (const octave_value& v) |
6874 | 2912 { |
7378 | 2913 graphics_handle val (v); |
7363 | 2914 |
6874 | 2915 if (error_state) |
2916 return; | |
2917 | |
7059 | 2918 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2919 { |
2920 currentfigure = val; | |
2921 | |
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
|
2922 if (val.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
|
2923 gh_manager::push_figure (val); |
6874 | 2924 } |
2925 else | |
2926 gripe_set_invalid ("currentfigure"); | |
2927 } | |
2928 | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2929 void |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2930 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
|
2931 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2932 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2933 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2934 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2935 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2936 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2937 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2938 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2939 if (! cbo_stack.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2940 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2941 val = cbo_stack.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2942 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2943 cbo_stack.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2944 } |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2945 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2946 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2947 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2948 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2949 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2950 if (get_callbackobject ().ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2951 cbo_stack.push_front (get_callbackobject ()); |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2952 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2953 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2954 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2955 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2956 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2957 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2958 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2959 void |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2960 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
|
2961 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2962 if (! error_state) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2963 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2964 if (integerhandle.set (val, true)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2965 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2966 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
|
2967 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2968 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
|
2969 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2970 graphics_handle old_myhandle = __myhandle__; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2971 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2972 __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
|
2973 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2974 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
|
2975 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2976 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
|
2977 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2978 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
|
2979 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2980 props.renumber_child (old_myhandle, __myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2981 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2982 Matrix kids = get_children (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2983 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2984 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
|
2985 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2986 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
|
2987 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2988 kid.get_properties ().renumber_parent (__myhandle__); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2989 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2990 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2991 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
|
2992 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2993 if (__myhandle__ == cf) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2994 xset (0, "currentfigure", __myhandle__.value ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2995 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2996 this_go.update (integerhandle.get_id ()); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2997 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2998 mark_modified (); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
2999 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3000 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3001 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
3002 |
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
|
3003 // FIXME This should update monitorpositions and pointerlocation, but |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3004 // 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
|
3005 // aren't set yet. |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3006 void |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3007 root_figure::properties::update_units (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3008 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3009 caseless_str xunits = get_units (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3010 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3011 Matrix ss = default_screensize (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3012 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3013 double dpi = get_screenpixelsperinch (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3014 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3015 if (xunits.compare ("inches")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3016 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3017 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3018 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3019 ss(2) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3020 ss(3) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3021 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3022 else if (xunits.compare ("centimeters")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3023 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3024 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3025 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3026 ss(2) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3027 ss(3) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3028 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3029 else if (xunits.compare ("normalized")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3030 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3031 ss = Matrix (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3032 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3033 else if (xunits.compare ("points")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3034 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3035 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3036 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3037 ss(2) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3038 ss(3) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3039 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3040 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3041 set_screensize (ss); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3042 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3043 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
3044 void |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3045 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
|
3046 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3047 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3048 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3049 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3050 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3051 xset (0, "currentfigure", cf.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3052 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3053 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3054 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3055 |
6406 | 3056 property_list |
3057 root_figure::factory_properties = root_figure::init_factory_properties (); | |
3058 | |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3059 static void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3060 reset_default_properties (property_list& default_properties) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3061 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3062 property_list new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3063 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3064 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
|
3065 p != default_properties.end (); p++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3066 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3067 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
|
3068 std::string prefix = p->first; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3069 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3070 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
|
3071 q != pval_map.end (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3072 q++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3073 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3074 std::string s = q->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3075 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3076 if (prefix == "axes" && (s == "position" || s == "units")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3077 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
|
3078 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
|
3079 || s == "windowstyle" |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3080 || s == "paperunits")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3081 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3082 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3083 } |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3084 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3085 default_properties = new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3086 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3087 |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3088 void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3089 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
|
3090 { |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3091 ::reset_default_properties (default_properties); |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3092 } |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3093 |
6406 | 3094 // --------------------------------------------------------------------- |
3095 | |
7363 | 3096 void |
3097 figure::properties::set_currentaxes (const octave_value& v) | |
3098 { | |
7378 | 3099 graphics_handle val (v); |
6705 | 3100 |
6874 | 3101 if (error_state) |
3102 return; | |
3103 | |
7070 | 3104 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 3105 currentaxes = val; |
3106 else | |
3107 gripe_set_invalid ("currentaxes"); | |
3108 } | |
3109 | |
3110 void | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3111 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
|
3112 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3113 base_properties::remove_child (gh); |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3114 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3115 if (gh == currentaxes.handle_value ()) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3116 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3117 graphics_handle new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3118 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3119 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
|
3120 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3121 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
|
3122 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3123 graphics_handle kid = kids(i); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3124 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3125 graphics_object go = gh_manager::get_object (kid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3126 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3127 if (go.isa ("axes")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3128 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3129 new_currentaxes = kid; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3130 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3131 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3132 } |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3133 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3134 currentaxes = new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3135 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3136 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3137 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3138 void |
6874 | 3139 figure::properties::set_visible (const octave_value& val) |
3140 { | |
3141 std::string s = val.string_value (); | |
3142 | |
3143 if (! error_state) | |
3144 { | |
3145 if (s == "on") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3146 xset (0, "currentfigure", __myhandle__.value ()); |
6874 | 3147 |
3148 visible = val; | |
3149 } | |
3150 } | |
3151 | |
7445 | 3152 Matrix |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3153 figure::properties::get_boundingbox (bool internal, const Matrix&) const |
7445 | 3154 { |
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
|
3155 Matrix screen_size = screen_size_pixels (); |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3156 Matrix pos = (internal ? |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3157 get_position ().matrix_value () : |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3158 get_outerposition ().matrix_value ()); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3159 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3160 pos = convert_position (pos, get_units (), "pixels", screen_size); |
7445 | 3161 |
3162 pos(0)--; | |
3163 pos(1)--; | |
7447 | 3164 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 3165 |
3166 return pos; | |
3167 } | |
3168 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3169 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3170 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
|
3171 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
|
3172 { |
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
|
3173 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
|
3174 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
|
3175 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3176 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
|
3177 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
|
3178 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
|
3179 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
|
3180 |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3181 if (internal) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3182 set_position (pos, do_notify_toolkit); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3183 else |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3184 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
|
3185 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3186 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3187 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3188 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
|
3189 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3190 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
|
3191 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
|
3192 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3193 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
|
3194 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
|
3195 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3196 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
|
3197 pos(0)++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3198 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
|
3199 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
|
3200 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3201 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3202 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3203 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3204 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3205 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
|
3206 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3207 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
|
3208 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
|
3209 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3210 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
|
3211 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
|
3212 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3213 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
|
3214 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
|
3215 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3216 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
|
3217 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3218 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3219 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3220 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3221 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3222 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
|
3223 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
|
3224 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3225 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
|
3226 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3227 Matrix old_bb, new_bb; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3228 |
13897
1367f2db49a2
Backed out changeset 5c2096009c43
John W. Eaton <jwe@octave.org>
parents:
13896
diff
changeset
|
3229 old_bb = get_boundingbox (); |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3230 position.set (v, true, do_notify_toolkit); |
13897
1367f2db49a2
Backed out changeset 5c2096009c43
John W. Eaton <jwe@octave.org>
parents:
13896
diff
changeset
|
3231 new_bb = get_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
|
3232 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3233 if (old_bb != new_bb) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3234 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3235 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
|
3236 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3237 execute_resizefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3238 update_boundingbox (); |
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 } |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3241 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3242 mark_modified (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3243 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3244 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3245 |
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
|
3246 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3247 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
|
3248 bool do_notify_toolkit) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3249 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3250 if (! error_state) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3251 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3252 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
|
3253 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3254 mark_modified (); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3255 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3256 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3257 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3258 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3259 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
|
3260 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
|
3261 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3262 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
|
3263 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3264 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
|
3265 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
|
3266 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
|
3267 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3268 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
|
3269 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
|
3270 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
|
3271 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3272 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
|
3273 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
|
3274 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3275 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
|
3276 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
|
3277 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3278 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3279 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3280 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3281 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3282 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3283 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
|
3284 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
|
3285 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3286 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
|
3287 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3288 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
|
3289 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
|
3290 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
|
3291 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3292 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
|
3293 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
|
3294 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
|
3295 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3296 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
|
3297 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3298 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
|
3299 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
|
3300 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3301 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3302 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3303 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3304 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3305 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3306 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
|
3307 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
|
3308 { |
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
|
3309 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
|
3310 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3311 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
|
3312 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3313 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
|
3314 double mm2units; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3315 |
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
|
3316 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
|
3317 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3318 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
|
3319 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
|
3320 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3321 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
|
3322 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3323 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
|
3324 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
|
3325 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3326 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
|
3327 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3328 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
|
3329 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
|
3330 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3331 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3332 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
|
3333 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3334 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
|
3335 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
|
3336 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3337 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
|
3338 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3339 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
|
3340 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
|
3341 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3342 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
|
3343 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3344 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
|
3345 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
|
3346 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3347 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
|
3348 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3349 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
|
3350 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
|
3351 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3352 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
|
3353 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3354 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
|
3355 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
|
3356 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3357 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
|
3358 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3359 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
|
3360 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
|
3361 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3362 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
|
3363 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3364 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
|
3365 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
|
3366 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3367 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
|
3368 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3369 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
|
3370 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
|
3371 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3372 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
|
3373 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3374 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
|
3375 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
|
3376 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3377 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
|
3378 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3379 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
|
3380 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
|
3381 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3382 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
|
3383 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3384 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
|
3385 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
|
3386 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3387 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
|
3388 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3389 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
|
3390 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
|
3391 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3392 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
|
3393 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3394 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
|
3395 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
|
3396 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3397 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
|
3398 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3399 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
|
3400 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
|
3401 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3402 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
|
3403 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3404 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
|
3405 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
|
3406 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3407 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
|
3408 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3409 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
|
3410 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
|
3411 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3412 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
|
3413 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3414 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
|
3415 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
|
3416 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3417 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
|
3418 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3419 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
|
3420 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
|
3421 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3422 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
|
3423 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3424 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
|
3425 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
|
3426 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3427 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
|
3428 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3429 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
|
3430 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
|
3431 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3432 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
|
3433 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3434 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
|
3435 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
|
3436 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3437 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
|
3438 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3439 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
|
3440 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
|
3441 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3442 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
|
3443 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3444 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
|
3445 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
|
3446 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3447 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
|
3448 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3449 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
|
3450 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
|
3451 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3452 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
|
3453 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3454 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
|
3455 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
|
3456 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3457 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3458 |
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
|
3459 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
|
3460 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3461 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3462 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
|
3463 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
|
3464 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3465 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
|
3466 Matrix sz = get_papersize ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3467 |
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
|
3468 pos (0) = pos (0) / sz(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
|
3469 pos (1) = pos (1) / sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3470 pos (2) = pos (2) / sz(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
|
3471 pos (3) = pos (3) / sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3472 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3473 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
|
3474 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
|
3475 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3476 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
|
3477 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3478 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
|
3479 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3480 sz (0) = sz (0) / 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
|
3481 sz (1) = sz (1) / 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
|
3482 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3483 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
|
3484 { |
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 sz (0) = sz (0) / 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
|
3486 sz (1) = sz (1) / 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
|
3487 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3488 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3489 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
|
3490 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3491 sz(0) = sz(0) * 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
|
3492 sz(1) = sz(1) * 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
|
3493 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3494 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
|
3495 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3496 sz (0) = sz (0) * 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
|
3497 sz (1) = sz (1) * 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
|
3498 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3499 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3500 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
|
3501 sz = papersize_from_type (punits, typ); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3502 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3503 pos (0) = pos (0) * sz(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
|
3504 pos (1) = pos (1) * sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3505 pos (2) = pos (2) * sz(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
|
3506 pos (3) = pos (3) * sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3507 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3508 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
|
3509 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
|
3510 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3511 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3512 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
|
3513 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
|
3514 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3515 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
|
3516 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3517 if (! typ.compare ("<custom>")) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3518 // Call papersize.set rather than set_papersize to avoid loops between |
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
|
3519 // update_papersize and 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
|
3520 papersize.set (octave_value (papersize_from_type (get_paperunits (), typ))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3521 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3522 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3523 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
|
3524 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
|
3525 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3526 papertype.set ("<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
|
3527 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3528 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3529 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
|
3530 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
|
3531 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3532 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
|
3533 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3534 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
|
3535 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
|
3536 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3537 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
|
3538 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
|
3539 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3540 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3541 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3542 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3543 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
|
3544 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
|
3545 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3546 set_position (convert_position (get_position ().matrix_value (), 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
|
3547 get_units (), screen_size_pixels ())); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3548 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3549 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3550 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3551 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3552 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3553 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3554 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3555 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
3556 std::string nm = get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3557 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3558 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
|
3559 if (! nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3560 os << ": " << get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3561 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3562 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3563 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3564 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3565 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3566 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3567 |
6836 | 3568 octave_value |
7189 | 3569 figure::get_default (const caseless_str& name) const |
6836 | 3570 { |
3571 octave_value retval = default_properties.lookup (name); | |
3572 | |
3573 if (retval.is_undefined ()) | |
3574 { | |
3575 graphics_handle parent = get_parent (); | |
3576 graphics_object parent_obj = gh_manager::get_object (parent); | |
3577 | |
3578 retval = parent_obj.get_default (name); | |
3579 } | |
3580 | |
3581 return retval; | |
3582 } | |
3583 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3584 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3585 figure::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3586 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3587 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3588 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3589 |
6406 | 3590 // --------------------------------------------------------------------- |
3591 | |
8249 | 3592 void |
3593 axes::properties::init (void) | |
3594 { | |
3595 position.add_constraint (dim_vector (1, 4)); | |
3596 position.add_constraint (dim_vector (0, 0)); | |
3597 outerposition.add_constraint (dim_vector (1, 4)); | |
3598 colororder.add_constraint (dim_vector (-1, 3)); | |
3599 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
3600 plotboxaspectratio.add_constraint (dim_vector (1, 3)); | |
3601 xlim.add_constraint (2); | |
3602 ylim.add_constraint (2); | |
3603 zlim.add_constraint (2); | |
3604 clim.add_constraint (2); | |
3605 alim.add_constraint (2); | |
3606 xtick.add_constraint (dim_vector (1, -1)); | |
3607 ytick.add_constraint (dim_vector (1, -1)); | |
3608 ztick.add_constraint (dim_vector (1, -1)); | |
3609 Matrix vw (1, 2, 0); | |
3610 vw(1) = 90; | |
3611 view = vw; | |
3612 view.add_constraint (dim_vector (1, 2)); | |
3613 cameraposition.add_constraint (dim_vector (1, 3)); | |
3614 Matrix upv (1, 3, 0.0); | |
3615 upv(2) = 1.0; | |
3616 cameraupvector = upv; | |
3617 cameraupvector.add_constraint (dim_vector (1, 3)); | |
3618 currentpoint.add_constraint (dim_vector (2, 3)); | |
3619 ticklength.add_constraint (dim_vector (1, 2)); | |
3620 tightinset.add_constraint (dim_vector (1, 4)); | |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3621 looseinset.add_constraint (dim_vector (1, 4)); |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
3622 update_font (); |
8249 | 3623 |
3624 x_zlim.resize (1, 2); | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3625 |
8249 | 3626 sx = "linear"; |
3627 sy = "linear"; | |
3628 sz = "linear"; | |
3629 | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3630 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3631 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3632 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3633 |
8249 | 3634 xset (xlabel.handle_value (), "handlevisibility", "off"); |
3635 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3636 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3637 xset (title.handle_value (), "handlevisibility", "off"); | |
3638 | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3639 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
|
3640 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3641 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
|
3642 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3643 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
|
3644 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3645 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
|
3646 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3647 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3648 xset (xlabel.handle_value (), "verticalalignment", "cap"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3649 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3650 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
|
3651 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3652 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
|
3653 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3654 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3655 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
|
3656 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
|
3657 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3658 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3659 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3660 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3661 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3662 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3663 xset (title.handle_value (), "clipping", "off"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3664 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3665 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
|
3666 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
|
3667 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
|
3668 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
|
3669 |
8249 | 3670 adopt (xlabel.handle_value ()); |
3671 adopt (ylabel.handle_value ()); | |
3672 adopt (zlabel.handle_value ()); | |
3673 adopt (title.handle_value ()); | |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3674 |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3675 Matrix tlooseinset = default_axes_position (); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3676 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3677 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3678 looseinset = tlooseinset; |
8249 | 3679 } |
3680 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3681 Matrix |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3682 axes::properties::calc_tightbox (const Matrix& init_pos) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3683 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3684 Matrix pos = init_pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3685 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
|
3686 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
|
3687 Matrix ext = get_extent (true, true); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3688 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
|
3689 ext(0)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3690 ext(1)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3691 ext = convert_position (ext, "pixels", get_units (), |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3692 parent_bb.extract_n (0, 2, 1, 2)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3693 if (ext(0) < pos(0)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3694 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3695 pos(2) += pos(0)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3696 pos(0) = ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3697 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3698 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
|
3699 pos(2) = ext(0)+ext(2)-pos(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3700 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3701 if (ext(1) < pos(1)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3702 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3703 pos(3) += pos(1)-ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3704 pos(1) = ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3705 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3706 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
|
3707 pos(3) = ext(1)+ext(3)-pos(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3708 return pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3709 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3710 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3711 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
|
3712 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
|
3713 { |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3714 Matrix ref_linset = looseinset.get ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3715 if (autopos_tag_is ("subplot")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3716 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3717 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3718 if (parent_obj.isa ("figure")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3719 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3720 // FIXME: temporarily changed units should be protected |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3721 // from interrupts |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3722 std::string fig_units = parent_obj.get ("units").string_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3723 parent_obj.set ("units", "pixels"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3724 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3725 Matrix ref_outbox = outerposition.get ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3726 ref_outbox(2) += ref_outbox(0); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3727 ref_outbox(3) += ref_outbox(1); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3728 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3729 // Find those subplots that are left, right, bottom and top aligned |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3730 // with the current subplot |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3731 Matrix kids = parent_obj.get_properties ().get_children (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3732 std::vector<octave_value> aligned; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3733 std::vector<bool> l_aligned, b_aligned, r_aligned, t_aligned; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3734 for (octave_idx_type i = 0; i < kids.numel (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3735 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3736 graphics_object go = gh_manager::get_object (kids(i)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3737 if (go.isa ("axes")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3738 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3739 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3740 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3741 if (props.autopos_tag_is("subplot")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3742 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3743 Matrix outpos = go.get ("outerposition").matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3744 bool l_align=(std::abs (outpos(0)-ref_outbox(0)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3745 bool b_align=(std::abs (outpos(1)-ref_outbox(1)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3746 bool r_align=(std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3747 bool t_align=(std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3748 if (l_align || b_align || r_align || t_align) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3749 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3750 aligned.push_back(kids(i)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3751 l_aligned.push_back(l_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3752 b_aligned.push_back(b_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3753 r_aligned.push_back(r_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3754 t_aligned.push_back(t_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3755 // FIXME: the temporarily deleted tags should be |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3756 // protected from interrupts |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3757 props.set_autopos_tag ("none"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3758 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3759 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3760 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3761 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3762 // Determine a minimum box which aligns the subplots |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3763 Matrix ref_box(1, 4, 0.); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3764 ref_box(2) = 1.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3765 ref_box(3) = 1.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3766 for (size_t i = 0; i < aligned.size (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3767 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3768 graphics_object go = gh_manager::get_object (aligned[i]); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3769 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3770 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3771 Matrix linset = props.get_looseinset ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3772 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3773 linset(0) = std::min (0., linset(0)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3774 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3775 linset(1) = std::min (0., linset(1)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3776 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3777 linset(2) = std::min (0., linset(2)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3778 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3779 linset(3) = std::min (0., linset(3)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3780 props.set_looseinset (linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3781 Matrix pos = props.get_position ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3782 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3783 ref_box(0) = std::max (ref_box(0), pos(0)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3784 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3785 ref_box(1) = std::max (ref_box(1), pos(1)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3786 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3787 ref_box(2) = std::min (ref_box(2), pos(0)+pos(2)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3788 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3789 ref_box(3) = std::min (ref_box(3), pos(1)+pos(3)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3790 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3791 // Set common looseinset values for all aligned subplots and |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3792 // revert their tag values |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3793 for (size_t i = 0; i < aligned.size (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3794 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3795 graphics_object go = gh_manager::get_object (aligned[i]); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3796 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3797 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3798 Matrix outpos = props.get_outerposition ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3799 Matrix linset = props.get_looseinset ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3800 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3801 linset(0) = (ref_box(0)-outpos(0))/outpos(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3802 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3803 linset(1) = (ref_box(1)-outpos(1))/outpos(3); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3804 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3805 linset(2) = (outpos(0)+outpos(2)-ref_box(2))/outpos(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3806 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3807 linset(3) = (outpos(1)+outpos(3)-ref_box(3))/outpos(3); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3808 props.set_looseinset (linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3809 props.set_autopos_tag ("subplot"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3810 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3811 parent_obj.set ("units", fig_units); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3812 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3813 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3814 else |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3815 sync_positions (ref_linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3816 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3817 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3818 void |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3819 axes::properties::sync_positions (const Matrix& linset) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3820 { |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3821 Matrix pos = position.get ().matrix_value (); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3822 Matrix outpos = outerposition.get ().matrix_value (); |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3823 double lratio = linset(0); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3824 double bratio = linset(1); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3825 double wratio = 1-linset(0)-linset(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3826 double hratio = 1-linset(1)-linset(3); |
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
|
3827 if (activepositionproperty.is ("outerposition")) |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3828 { |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3829 pos = outpos; |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3830 pos(0) = outpos(0)+lratio*outpos(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3831 pos(1) = outpos(1)+bratio*outpos(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3832 pos(2) = wratio*outpos(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3833 pos(3) = hratio*outpos(3); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3834 |
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
|
3835 position = pos; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3836 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3837 Matrix tightpos = calc_tightbox (pos); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3838 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3839 double thrshldx = 0.005*outpos(2); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3840 double thrshldy = 0.005*outpos(3); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3841 double minsizex = 0.2*outpos(2); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3842 double minsizey = 0.2*outpos(3); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
3843 bool updatex = true, updatey = true; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3844 for (int i = 0; i < 10; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3845 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3846 double dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3847 bool modified = false; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3848 dt = outpos(0)+outpos(2)-tightpos(0)-tightpos(2); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3849 if (dt < -thrshldx && updatex) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3850 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3851 pos(2) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3852 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3853 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3854 dt = outpos(1)+outpos(3)-tightpos(1)-tightpos(3); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3855 if (dt < -thrshldy && updatey) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3856 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3857 pos(3) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3858 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3859 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3860 dt = outpos(0)-tightpos(0); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3861 if (dt > thrshldx && updatex) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3862 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3863 pos(0) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3864 pos(2) -= dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3865 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3866 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3867 dt = outpos(1)-tightpos(1); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3868 if (dt > thrshldy && updatey) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3869 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3870 pos(1) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3871 pos(3) -= dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3872 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3873 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3874 |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3875 // Note: checking limit for minimum axes size |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3876 if (pos(2) < minsizex) |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3877 { |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3878 pos(0) -= 0.5*(minsizex-pos(2)); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3879 pos(2) = minsizex; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3880 updatex = false; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3881 } |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3882 if (pos(3) < minsizey) |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3883 { |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3884 pos(1) -= 0.5*(minsizey-pos(3)); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3885 pos(3) = minsizey; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3886 updatey = false; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3887 } |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3888 |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3889 if (modified) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3890 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3891 position = pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3892 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3893 tightpos = calc_tightbox (pos); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3894 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3895 else |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3896 break; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3897 } |
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
|
3898 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3899 else |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3900 { |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3901 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3902 |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3903 outpos(0) = pos(0)-pos(2)*lratio/wratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3904 outpos(1) = pos(1)-pos(3)*bratio/hratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3905 outpos(2) = pos(2)/wratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3906 outpos(3) = pos(3)/hratio; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3907 |
12458
68daf2a0b56d
fix a small bug introduced on 2011-02-14
Konstantinos Poulios <logari81@googlemail.com>
parents:
12449
diff
changeset
|
3908 outerposition = calc_tightbox (outpos); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3909 } |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3910 |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3911 Matrix inset (1, 4, 1.0); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3912 inset(0) = pos(0)-outpos(0); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3913 inset(1) = pos(1)-outpos(1); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3914 inset(2) = outpos(0)+outpos(2)-pos(0)-pos(2); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3915 inset(3) = outpos(1)+outpos(3)-pos(1)-pos(3); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
3916 |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3917 tightinset = inset; |
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
|
3918 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3919 |
7363 | 3920 void |
8249 | 3921 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
|
3922 const std::string& who, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3923 const octave_value& v) |
6962 | 3924 { |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3925 graphics_handle val; |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3926 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3927 if (v.is_string ()) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3928 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
3929 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
|
3930 false, false); |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3931 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3932 xset (val, "string", v); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3933 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3934 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3935 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3936 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
|
3937 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3938 if (go.isa ("text")) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3939 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
|
3940 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3941 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3942 std::string cname = v.class_name (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3943 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3944 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
|
3945 who.c_str (), cname.c_str ()); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3946 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3947 } |
6962 | 3948 |
6874 | 3949 if (! error_state) |
3950 { | |
8249 | 3951 xset (val, "handlevisibility", "off"); |
3952 | |
3953 gh_manager::free (hp.handle_value ()); | |
3954 | |
3955 base_properties::remove_child (hp.handle_value ()); | |
3956 | |
3957 hp = val; | |
3958 | |
3959 adopt (hp.handle_value ()); | |
6874 | 3960 } |
3961 } | |
3962 | |
3963 void | |
7363 | 3964 axes::properties::set_xlabel (const octave_value& v) |
6874 | 3965 { |
8249 | 3966 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
|
3967 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
|
3968 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
|
3969 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
|
3970 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
|
3971 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
|
3972 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
|
3973 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
|
3974 update_xlabel_position (); |
6874 | 3975 } |
3976 | |
3977 void | |
7363 | 3978 axes::properties::set_ylabel (const octave_value& v) |
6874 | 3979 { |
8249 | 3980 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
|
3981 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
|
3982 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
|
3983 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
|
3984 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
|
3985 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
|
3986 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
|
3987 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
|
3988 update_ylabel_position (); |
6874 | 3989 } |
3990 | |
3991 void | |
7363 | 3992 axes::properties::set_zlabel (const octave_value& v) |
6874 | 3993 { |
8249 | 3994 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
|
3995 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
|
3996 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
|
3997 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
|
3998 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
|
3999 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
|
4000 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
|
4001 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
|
4002 update_zlabel_position (); |
8249 | 4003 } |
4004 | |
4005 void | |
4006 axes::properties::set_title (const octave_value& v) | |
4007 { | |
4008 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
|
4009 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
|
4010 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
|
4011 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
|
4012 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
|
4013 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
|
4014 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
|
4015 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
|
4016 update_title_position (); |
6874 | 4017 } |
4018 | |
4019 void | |
6844 | 4020 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
|
4021 const std::string& mode) |
6705 | 4022 { |
4023 box = "on"; | |
6962 | 4024 colororder = default_colororder (); |
6705 | 4025 dataaspectratio = Matrix (1, 3, 1.0); |
4026 dataaspectratiomode = "auto"; | |
7363 | 4027 layer = "bottom"; |
6705 | 4028 |
4029 Matrix tlim (1, 2, 0.0); | |
4030 tlim(1) = 1; | |
4031 xlim = tlim; | |
4032 ylim = tlim; | |
4033 zlim = tlim; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4034 |
6807 | 4035 Matrix cl (1, 2, 0); |
4036 cl(1) = 1; | |
4037 clim = cl; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4038 |
7363 | 4039 xlimmode = "auto"; |
4040 ylimmode = "auto"; | |
4041 zlimmode = "auto"; | |
4042 climmode = "auto"; | |
8208 | 4043 |
6705 | 4044 xgrid = "off"; |
4045 ygrid = "off"; | |
4046 zgrid = "off"; | |
4047 xminorgrid = "off"; | |
4048 yminorgrid = "off"; | |
4049 zminorgrid = "off"; | |
4050 xtick = Matrix (); | |
4051 ytick = Matrix (); | |
4052 ztick = Matrix (); | |
4053 xtickmode = "auto"; | |
4054 ytickmode = "auto"; | |
4055 ztickmode = "auto"; | |
4056 xticklabel = ""; | |
4057 yticklabel = ""; | |
4058 zticklabel = ""; | |
4059 xticklabelmode = "auto"; | |
4060 yticklabelmode = "auto"; | |
4061 zticklabelmode = "auto"; | |
10565
2880a862b1a8
Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents:
10553
diff
changeset
|
4062 color = "none"; |
7364 | 4063 xcolor = color_values ("black"); |
4064 ycolor = color_values ("black"); | |
4065 zcolor = color_values ("black"); | |
7363 | 4066 xscale = "linear"; |
4067 yscale = "linear"; | |
4068 zscale = "linear"; | |
6705 | 4069 xdir = "normal"; |
4070 ydir = "normal"; | |
4071 zdir = "normal"; | |
7363 | 4072 yaxislocation = "left"; |
4073 xaxislocation = "bottom"; | |
6705 | 4074 |
7427 | 4075 // Note: camera properties will be set through update_transform |
4076 camerapositionmode = "auto"; | |
4077 cameratargetmode = "auto"; | |
4078 cameraupvectormode = "auto"; | |
4079 cameraviewanglemode = "auto"; | |
4080 plotboxaspectratio = Matrix (1, 3, 1.0); | |
4081 drawmode = "normal"; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4082 gridlinestyle = ":"; |
7427 | 4083 linestyleorder = "-"; |
4084 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4085 minorgridlinestyle = ":"; |
7427 | 4086 // Note: plotboxaspectratio will be set through update_aspectratiors |
4087 plotboxaspectratiomode = "auto"; | |
4088 projection = "orthographic"; | |
4089 tickdir = "in"; | |
4090 tickdirmode = "auto"; | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
4091 ticklength = default_axes_ticklength (); |
7427 | 4092 tightinset = Matrix (1, 4, 0.0); |
4093 | |
4094 sx = "linear"; | |
4095 sy = "linear"; | |
4096 sz = "linear"; | |
4097 | |
6705 | 4098 Matrix tview (1, 2, 0.0); |
4099 tview(1) = 90; | |
4100 view = tview; | |
4101 | |
6765 | 4102 visible = "on"; |
6705 | 4103 nextplot = "replace"; |
4104 | |
4105 if (mode != "replace") | |
4106 { | |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4107 fontangle = "normal"; |
8944
cb0e9facc342
make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
4108 fontname = OCTAVE_DEFAULT_FONTNAME; |
11384
1511bbfe6a6e
Change axes default fontsize from 12 to 10.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11283
diff
changeset
|
4109 fontsize = 10; |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4110 fontunits = "points"; |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4111 fontweight = "normal"; |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4112 |
6406 | 4113 Matrix touterposition (1, 4, 0.0); |
4114 touterposition(2) = 1; | |
4115 touterposition(3) = 1; | |
4116 outerposition = touterposition; | |
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
|
4117 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
4118 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
|
4119 |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4120 Matrix tlooseinset = default_axes_position (); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4121 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4122 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4123 looseinset = tlooseinset; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4124 |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4125 activepositionproperty = "outerposition"; |
6406 | 4126 } |
4127 | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4128 delete_children (true); |
6432 | 4129 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4130 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
|
4131 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4132 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4133 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
|
4134 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4135 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4136 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
|
4137 false, false); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4138 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4139 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
|
4140 false, false); |
8249 | 4141 |
4142 xset (xlabel.handle_value (), "handlevisibility", "off"); | |
4143 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
4144 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
4145 xset (title.handle_value (), "handlevisibility", "off"); | |
4146 | |
8636 | 4147 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
|
4148 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4149 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
|
4150 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4151 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
|
4152 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4153 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
|
4154 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4155 |
4156 xset (xlabel.handle_value (), "verticalalignment", "cap"); | |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4157 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4158 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
|
4159 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4160 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
|
4161 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4162 |
4163 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
|
4164 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
|
4165 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4166 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4167 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4168 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4169 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4170 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4171 xset (title.handle_value (), "clipping", "off"); |
8636 | 4172 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4173 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
|
4174 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
|
4175 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
|
4176 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
|
4177 |
8249 | 4178 adopt (xlabel.handle_value ()); |
4179 adopt (ylabel.handle_value ()); | |
4180 adopt (zlabel.handle_value ()); | |
4181 adopt (title.handle_value ()); | |
4182 | |
7427 | 4183 update_transform (); |
4184 | |
6705 | 4185 override_defaults (obj); |
4186 } | |
4187 | |
8208 | 4188 void |
4189 axes::properties::delete_text_child (handle_property& hp) | |
6874 | 4190 { |
8208 | 4191 graphics_handle h = hp.handle_value (); |
4192 | |
4193 if (h.ok ()) | |
4194 { | |
4195 graphics_object go = gh_manager::get_object (h); | |
4196 | |
4197 if (go.valid_object ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4198 gh_manager::free (h); |
8249 | 4199 |
4200 base_properties::remove_child (h); | |
8208 | 4201 } |
4202 | |
8249 | 4203 // FIXME -- is it necessary to check whether the axes object is |
4204 // being deleted now? I think this function is only called when an | |
4205 // individual child object is delete and not when the parent axes | |
4206 // object is deleted. | |
4207 | |
8208 | 4208 if (! is_beingdeleted ()) |
8249 | 4209 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
4210 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
|
4211 false, false); |
8249 | 4212 |
4213 xset (hp.handle_value (), "handlevisibility", "off"); | |
4214 | |
4215 adopt (hp.handle_value ()); | |
4216 } | |
6705 | 4217 } |
6406 | 4218 |
6705 | 4219 void |
6844 | 4220 axes::properties::remove_child (const graphics_handle& h) |
6705 | 4221 { |
8249 | 4222 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
8208 | 4223 delete_text_child (xlabel); |
7363 | 4224 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
8208 | 4225 delete_text_child (ylabel); |
7363 | 4226 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
8208 | 4227 delete_text_child (zlabel); |
8249 | 4228 else if (title.handle_value ().ok () && h == title.handle_value ()) |
4229 delete_text_child (title); | |
6705 | 4230 else |
4231 base_properties::remove_child (h); | |
4232 } | |
6406 | 4233 |
7427 | 4234 inline Matrix |
4235 xform_matrix (void) | |
4236 { | |
4237 Matrix m (4, 4, 0.0); | |
4238 for (int i = 0; i < 4; i++) | |
4239 m(i,i) = 1; | |
4240 return m; | |
4241 } | |
4242 | |
4243 inline ColumnVector | |
4244 xform_vector (void) | |
4245 { | |
4246 ColumnVector v (4, 0.0); | |
4247 v(3) = 1; | |
4248 return v; | |
4249 } | |
4250 | |
4251 inline ColumnVector | |
4252 xform_vector (double x, double y, double z) | |
4253 { | |
4254 ColumnVector v (4, 1.0); | |
4255 v(0) = x; v(1) = y; v(2) = z; | |
4256 return v; | |
4257 } | |
4258 | |
4259 inline ColumnVector | |
4260 transform (const Matrix& m, double x, double y, double z) | |
4261 { | |
4262 return (m * xform_vector (x, y, z)); | |
4263 } | |
4264 | |
4265 inline Matrix | |
4266 xform_scale (double x, double y, double z) | |
4267 { | |
4268 Matrix m (4, 4, 0.0); | |
4269 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
4270 return m; | |
4271 } | |
4272 | |
4273 inline Matrix | |
4274 xform_translate (double x, double y, double z) | |
4275 { | |
4276 Matrix m = xform_matrix (); | |
4277 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
4278 return m; | |
4279 } | |
4280 | |
4281 inline void | |
4282 scale (Matrix& m, double x, double y, double z) | |
4283 { | |
4284 m = m * xform_scale (x, y, z); | |
4285 } | |
4286 | |
4287 inline void | |
4288 translate (Matrix& m, double x, double y, double z) | |
4289 { | |
4290 m = m * xform_translate (x, y, z); | |
4291 } | |
4292 | |
4293 inline void | |
4294 xform (ColumnVector& v, const Matrix& m) | |
4295 { | |
4296 v = m*v; | |
4297 } | |
4298 | |
4299 inline void | |
4300 scale (ColumnVector& v, double x, double y, double z) | |
4301 { | |
4302 v(0) *= x; | |
4303 v(1) *= y; | |
4304 v(2) *= z; | |
4305 } | |
4306 | |
4307 inline void | |
4308 translate (ColumnVector& v, double x, double y, double z) | |
4309 { | |
4310 v(0) += x; | |
4311 v(1) += y; | |
4312 v(2) += z; | |
4313 } | |
4314 | |
4315 inline void | |
4316 normalize (ColumnVector& v) | |
4317 { | |
4318 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); | |
4319 scale (v, fact, fact, fact); | |
4320 } | |
4321 | |
4322 inline double | |
4323 dot (const ColumnVector& v1, const ColumnVector& v2) | |
4324 { | |
4325 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
4326 } | |
4327 | |
4328 inline double | |
4329 norm (const ColumnVector& v) | |
4330 { | |
4331 return sqrt (dot (v, v)); | |
4332 } | |
4333 | |
4334 inline ColumnVector | |
4335 cross (const ColumnVector& v1, const ColumnVector& v2) | |
4336 { | |
4337 ColumnVector r = xform_vector (); | |
4338 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
4339 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
4340 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
4341 return r; | |
4342 } | |
4343 | |
4344 inline Matrix | |
4345 unit_cube (void) | |
4346 { | |
4347 static double data[32] = { | |
4348 0,0,0,1, | |
4349 1,0,0,1, | |
4350 0,1,0,1, | |
4351 0,0,1,1, | |
4352 1,1,0,1, | |
4353 1,0,1,1, | |
4354 0,1,1,1, | |
4355 1,1,1,1}; | |
4356 Matrix m (4, 8); | |
4357 memcpy (m.fortran_vec (), data, sizeof(double)*32); | |
4358 return m; | |
4359 } | |
4360 | |
4361 inline ColumnVector | |
4362 cam2xform (const Array<double>& m) | |
4363 { | |
4364 ColumnVector retval (4, 1.0); | |
4365 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); | |
4366 return retval; | |
4367 } | |
4368 | |
4369 inline RowVector | |
4370 xform2cam (const ColumnVector& v) | |
4371 { | |
4372 return v.extract_n (0, 3).transpose (); | |
4373 } | |
4374 | |
4375 void | |
4376 axes::properties::update_camera (void) | |
4377 { | |
4378 double xd = (xdir_is ("normal") ? 1 : -1); | |
4379 double yd = (ydir_is ("normal") ? 1 : -1); | |
4380 double zd = (zdir_is ("normal") ? 1 : -1); | |
4381 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4382 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
|
4383 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
|
4384 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
|
4385 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4386 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
|
4387 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
|
4388 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
|
4389 |
7427 | 4390 Matrix pb = get_plotboxaspectratio ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4391 |
7427 | 4392 bool autocam = (camerapositionmode_is ("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4393 && cameratargetmode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4394 && cameraupvectormode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4395 && cameraviewanglemode_is ("auto")); |
7427 | 4396 bool dowarp = (autocam && dataaspectratiomode_is("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4397 && plotboxaspectratiomode_is ("auto")); |
7427 | 4398 |
4399 ColumnVector c_eye (xform_vector ()); | |
4400 ColumnVector c_center (xform_vector ()); | |
4401 ColumnVector c_upv (xform_vector ()); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4402 |
7427 | 4403 if (cameratargetmode_is ("auto")) |
4404 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4405 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
|
4406 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
|
4407 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 4408 |
4409 cameratarget = xform2cam (c_center); | |
4410 } | |
4411 else | |
4412 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
|
4413 |
7427 | 4414 if (camerapositionmode_is ("auto")) |
4415 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4416 Matrix tview = get_view ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4417 double az = tview(0), el = tview(1); |
7427 | 4418 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
4419 | |
4420 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4421 c_eye(2) = d*signum(el); |
7427 | 4422 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4423 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4424 az *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4425 el *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4426 c_eye(0) = d*cos(el)*sin(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4427 c_eye(1) = -d*cos(el)*cos(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4428 c_eye(2) = d*sin(el); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4429 } |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4430 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
|
4431 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
|
4432 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 4433 |
4434 cameraposition = xform2cam (c_eye); | |
4435 } | |
4436 else | |
4437 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
4438 | |
4439 if (cameraupvectormode_is ("auto")) | |
4440 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4441 Matrix tview = get_view ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4442 double az = tview(0), el = tview(1); |
7427 | 4443 |
4444 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4445 { |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4446 c_upv(0) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4447 -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4448 c_upv(1) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4449 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
|
4450 } |
7427 | 4451 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4452 c_upv(2) = 1; |
7427 | 4453 |
4454 cameraupvector = xform2cam (c_upv); | |
4455 } | |
4456 else | |
4457 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
4458 | |
4459 Matrix x_view = xform_matrix (); | |
4460 Matrix x_projection = xform_matrix (); | |
4461 Matrix x_viewport = xform_matrix (); | |
4462 Matrix x_normrender = xform_matrix (); | |
4463 Matrix x_pre = xform_matrix (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4464 |
7427 | 4465 x_render = xform_matrix (); |
4466 x_render_inv = xform_matrix (); | |
4467 | |
4468 scale (x_pre, pb(0), pb(1), pb(2)); | |
4469 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
|
4470 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
|
4471 zd/(zlimits(1)-zlimits(0))); |
7427 | 4472 translate (x_pre, -xo, -yo, -zo); |
4473 | |
4474 xform (c_eye, x_pre); | |
4475 xform (c_center, x_pre); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4476 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
|
4477 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 4478 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
4479 | |
4480 ColumnVector F (c_center), f (F), UP (c_upv); | |
4481 normalize (f); | |
4482 normalize (UP); | |
4483 | |
7440 | 4484 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 4485 { |
4486 double fa = 1/sqrt(1-f(2)*f(2)); | |
4487 scale (UP, fa, fa, fa); | |
4488 } | |
4489 | |
4490 ColumnVector s = cross (f, UP); | |
4491 ColumnVector u = cross (s, f); | |
4492 | |
4493 scale (x_view, 1, 1, -1); | |
4494 Matrix l = xform_matrix (); | |
4495 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
4496 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
4497 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
4498 x_view = x_view * l; | |
4499 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
4500 scale (x_view, pb(0), pb(1), pb(2)); | |
4501 translate (x_view, -0.5, -0.5, -0.5); | |
4502 | |
4503 Matrix x_cube = x_view * unit_cube (); | |
4504 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max (); | |
4505 double xM = cmax(0)-cmin(0); | |
4506 double yM = cmax(1)-cmin(1); | |
4507 | |
7447 | 4508 Matrix bb = get_boundingbox (true); |
7427 | 4509 |
4510 double v_angle; | |
4511 | |
4512 if (cameraviewanglemode_is ("auto")) | |
4513 { | |
4514 double af; | |
4515 | |
8333 | 4516 // FIXME -- was this really needed? When compared to Matlab, it |
7427 | 4517 // 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
|
4518 // graphics toolkit to see results visually. |
7427 | 4519 if (false && dowarp) |
4520 af = 1.0 / (xM > yM ? xM : yM); | |
4521 else | |
4522 { | |
4523 if ((bb(2)/bb(3)) > (xM/yM)) | |
4524 af = 1.0 / yM; | |
4525 else | |
4526 af = 1.0 / xM; | |
4527 } | |
4528 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
4529 | |
4530 cameraviewangle = v_angle; | |
4531 } | |
4532 else | |
4533 v_angle = get_cameraviewangle (); | |
4534 | |
4535 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
4536 scale (x_projection, pf, pf, 1); | |
4537 | |
4538 if (dowarp) | |
4539 { | |
4540 xM *= pf; | |
4541 yM *= pf; | |
7447 | 4542 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 4543 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
4544 } | |
4545 else | |
4546 { | |
4547 double pix = 1; | |
4548 if (autocam) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4549 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4550 if ((bb(2)/bb(3)) > (xM/yM)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4551 pix = bb(3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4552 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4553 pix = bb(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4554 } |
7427 | 4555 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4556 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); |
7447 | 4557 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 4558 scale (x_viewport, pix, -pix, 1); |
4559 } | |
4560 | |
4561 x_normrender = x_viewport * x_projection * x_view; | |
4562 | |
4563 x_cube = x_normrender * unit_cube (); | |
4564 cmin = x_cube.row_min (); | |
4565 cmax = x_cube.row_max (); | |
4566 x_zlim.resize (1, 2); | |
4567 x_zlim(0) = cmin(2); | |
4568 x_zlim(1) = cmax(2); | |
4569 | |
4570 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
|
4571 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
|
4572 zd/(zlimits(1)-zlimits(0))); |
7427 | 4573 translate (x_render, -xo, -yo, -zo); |
4574 | |
4575 x_viewtransform = x_view; | |
4576 x_projectiontransform = x_projection; | |
4577 x_viewporttransform = x_viewport; | |
4578 x_normrendertransform = x_normrender; | |
4579 x_rendertransform = x_render; | |
4580 | |
4581 x_render_inv = x_render.inverse (); | |
4582 | |
4583 // Note: these matrices are a slight modified version of the regular | |
4584 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
4585 // => x_gl_mat2) | |
4586 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
|
4587 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
|
4588 zd/(zlimits(1)-zlimits(0))); |
7427 | 4589 translate (x_gl_mat1, -xo, -yo, -zo); |
4590 x_gl_mat2 = x_viewport * x_projection; | |
4591 } | |
4592 | |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4593 static bool updating_axes_layout = false; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4594 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4595 void |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4596 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
|
4597 { |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4598 if (updating_axes_layout) |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4599 return; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4600 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4601 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
|
4602 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4603 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
|
4604 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
|
4605 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
|
4606 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4607 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
|
4608 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
|
4609 const Matrix zlims = xform.zscale (get_zlim ().matrix_value ()); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4610 double x_min = xlims(0), x_max = xlims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4611 double y_min = ylims(0), y_max = ylims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4612 double z_min = zlims(0), z_max = zlims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4613 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4614 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
|
4615 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4616 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
|
4617 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4618 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
|
4619 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
|
4620 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
|
4621 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
|
4622 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
|
4623 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
|
4624 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
|
4625 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
|
4626 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4627 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
|
4628 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
|
4629 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
|
4630 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
|
4631 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4632 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4633 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4634 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4635 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4636 xPlane = (dir(0) > 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4637 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4638 xPlane = (dir(1) < 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4639 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4640 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4641 xPlane = (dir(2) < 0 ? x_min : x_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4642 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4643 xPlaneN = (xPlane == x_min ? x_max : x_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4644 fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4645 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4646 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
|
4647 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
|
4648 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
|
4649 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
|
4650 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
|
4651 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
|
4652 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
|
4653 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
|
4654 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4655 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
|
4656 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
|
4657 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
|
4658 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
|
4659 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4660 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4661 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4662 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4663 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4664 yPlane = (dir(0) > 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4665 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4666 yPlane = (dir(1) < 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4667 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4668 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4669 yPlane = (dir(2) < 0 ? y_min : y_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4670 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4671 yPlaneN = (yPlane == y_min ? y_max : y_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4672 fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4673 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4674 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4675 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4676 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
|
4677 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
|
4678 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
|
4679 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
|
4680 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
|
4681 else if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4682 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4683 if (dir(0) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4684 zstate = AXE_VERT_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4685 else if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4686 zstate = AXE_HORZ_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4687 } |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4688 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4689 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4690 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4691 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4692 zPlane = (dir(0) > 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4693 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4694 zPlane = (dir(1) < 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4695 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4696 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4697 zPlane = (dir(2) < 0 ? z_min : z_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4698 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4699 zPlaneN = (zPlane == z_min ? z_max : z_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4700 fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4701 |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4702 unwind_protect frame; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4703 frame.protect_var (updating_axes_layout); |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4704 updating_axes_layout = true; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4705 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4706 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
|
4707 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
|
4708 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
|
4709 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
|
4710 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
|
4711 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
|
4712 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
|
4713 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
|
4714 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
|
4715 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4716 /* 2D mode */ |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4717 x2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4718 y2Dright = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4719 layer2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4720 if (xstate == AXE_HORZ_DIR && 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
|
4721 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4722 if (xaxislocation_is ("top")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4723 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4724 double tmp = yPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4725 yPlane = yPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4726 yPlaneN = tmp; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4727 x2Dtop = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4728 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4729 ypTick = yPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4730 ypTickN = yPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4731 if (yaxislocation_is ("right")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4732 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4733 double tmp = xPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4734 xPlane = xPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4735 xPlaneN = tmp; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4736 y2Dright = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4737 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4738 xpTick = xPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4739 xpTickN = xPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4740 if (layer_is ("top")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4741 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4742 zpTick = zPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4743 layer2Dtop = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4744 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4745 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4746 zpTick = zPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4747 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4748 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4749 Matrix viewmat = get_view ().matrix_value (); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4750 nearhoriz = std::abs(viewmat(1)) <= 5; |
13830
462b5f556346
avoid uninitialized variable warning from valgrind
John W. Eaton <jwe@octave.org>
parents:
13816
diff
changeset
|
4751 |
462b5f556346
avoid uninitialized variable warning from valgrind
John W. Eaton <jwe@octave.org>
parents:
13816
diff
changeset
|
4752 update_ticklengths (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4753 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4754 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4755 void |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4756 axes::properties::update_ticklengths (void) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4757 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4758 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
|
4759 (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
|
4760 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4761 if (tickdirmode_is ("auto")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4762 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4763 // FIXME: tickdir should be updated (code below comes |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4764 // from JHandles) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4765 //autoMode++; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4766 //TickDir.set(mode2d ? "in" : "out", true); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4767 //autoMode--; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4768 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4769 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4770 //double ticksign = (tickdir_is ("in") ? -1 : 1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4771 double ticksign = (tickdirmode_is ("auto") ? |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4772 (mode2d ? -1 : 1) : |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4773 (tickdir_is ("in") ? -1 : 1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4774 // FIXME: use ticklength property |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4775 xticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4776 yticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4777 zticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4778 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4779 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
|
4780 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
|
4781 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
|
4782 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4783 update_xlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4784 update_ylabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4785 update_zlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4786 update_title_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4787 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4788 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4789 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
|
4790 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4791 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4792 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
|
4793 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4794 if (updating_xlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4795 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4796 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4797 text::properties& xlabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4798 (gh_manager::get_object (get_xlabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4799 |
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
|
4800 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
|
4801 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4802 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4803 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
|
4804 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
|
4805 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4806 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4807 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4808 if (xlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4809 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4810 xlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4811 (xstate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4812 ? "center" : (xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4813 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4814 xlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4815 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4816 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4817 if (xlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4818 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4819 xlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4820 (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
|
4821 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4822 xlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4823 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4824 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4825 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4826 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
|
4827 || 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
|
4828 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4829 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
|
4830 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4831 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
|
4832 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
|
4833 get_xticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4834 get_xlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4835 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4836 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4837 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4838 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
|
4839 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4840 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
|
4841 if (tick_along_z) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4842 p(2) += (signum(zpTick-zpTickN)*fz*xtickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4843 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4844 p(1) += (signum(ypTick-ypTickN)*fy*xtickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4845 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4846 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
|
4847 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4848 switch (xstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4849 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4850 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4851 p(0) += (xyzSym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4852 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4853 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4854 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4855 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4856 p(0) -= wmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4857 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4858 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4859 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4860 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4861 p(1) += (x2Dtop ? -hmax : hmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4862 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4863 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4864 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4865 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
|
4866 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4867 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
|
4868 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
|
4869 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
|
4870 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4871 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4872 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
|
4873 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4874 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
|
4875 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
|
4876 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4877 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4878 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4879 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4880 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
|
4881 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4882 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4883 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
|
4884 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4885 if (updating_ylabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4886 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4887 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4888 text::properties& ylabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4889 (gh_manager::get_object (get_ylabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4890 |
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
|
4891 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
|
4892 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4893 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4894 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
|
4895 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
|
4896 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4897 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4898 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4899 if (ylabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4900 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4901 ylabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4902 (ystate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4903 ? "center" : (!xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4904 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4905 ylabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4906 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4907 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4908 if (ylabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4909 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4910 ylabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4911 (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
|
4912 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4913 ylabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4914 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4915 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4916 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4917 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
|
4918 || 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
|
4919 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4920 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
|
4921 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4922 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
|
4923 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
|
4924 get_yticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4925 get_ylim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4926 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4927 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4928 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4929 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
|
4930 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4931 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
|
4932 if (tick_along_z) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4933 p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4934 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4935 p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4936 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4937 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
|
4938 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4939 switch (ystate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4940 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4941 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4942 p(0) += (!xyzSym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4943 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4944 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4945 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4946 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4947 p(0) += (y2Dright ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4948 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4949 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4950 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4951 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4952 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4953 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4954 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4955 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4956 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
|
4957 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4958 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
|
4959 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
|
4960 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
|
4961 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4962 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4963 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
|
4964 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4965 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
|
4966 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
|
4967 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4968 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4969 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4970 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4971 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
|
4972 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4973 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4974 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
|
4975 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4976 if (updating_zlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4977 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4978 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4979 text::properties& zlabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4980 (gh_manager::get_object (get_zlabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4981 |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4982 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
|
4983 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
|
4984 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4985 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4986 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
|
4987 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
|
4988 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4989 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4990 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4991 if (zlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4992 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4993 zlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4994 ((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
|
4995 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4996 zlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4997 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4998 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4999 if (zlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5000 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5001 zlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5002 (zstate == AXE_VERT_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5003 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5004 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5005 zlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5006 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5007 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5008 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5009 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
|
5010 || 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
|
5011 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5012 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
|
5013 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5014 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
|
5015 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
|
5016 get_zticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5017 get_zlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5018 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5019 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5020 ColumnVector p; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5021 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5022 if (xySym) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5023 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5024 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
|
5025 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5026 if (xisinf (fy)) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5027 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5028 else |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5029 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5030 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5031 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5032 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5033 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
|
5034 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5035 if (xisinf (fx)) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5036 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5037 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5038 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5039 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5040 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5041 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
|
5042 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5043 switch (zstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5044 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5045 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5046 if (camAuto) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5047 { |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5048 p(0) -= wmax; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
5049 angle = 90; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5050 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5051 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5052 // FIXME -- what's the correct offset? |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5053 // |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5054 // p[0] += (!xySym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5055 // p[1] += (zSign ? hmax : -hmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5056 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5057 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5058 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5059 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5060 p(0) -= wmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5061 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5062 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5063 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5064 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5065 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5066 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5067 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5068 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5069 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
|
5070 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5071 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
|
5072 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
|
5073 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
|
5074 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5075 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5076 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
|
5077 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5078 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
|
5079 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
|
5080 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5081 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5082 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5083 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5084 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
|
5085 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5086 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5087 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
|
5088 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5089 if (updating_title_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5090 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5091 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5092 text::properties& title_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5093 (gh_manager::get_object (get_title ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5094 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5095 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5096 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
|
5097 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
|
5098 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5099 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
|
5100 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5101 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
|
5102 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5103 // 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
|
5104 Matrix bbox = get_extent (false); |
13910
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5105 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5106 ColumnVector p = |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5107 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
|
5108 bbox(1)-10, |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5109 (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
|
5110 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5111 if (x2Dtop) |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5112 { |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5113 Matrix ext (1, 2, 0.0); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5114 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
|
5115 get_xticklabel ().all_strings (), |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5116 get_xlim ().matrix_value ()); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5117 p(1) -= ext(1); |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5118 } |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5119 |
2af665333b86
title positioning taking xaxislocation into account (bug #33418)
Konstantinos Poulios <logari81@googlemail.com>
parents:
13908
diff
changeset
|
5120 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
|
5121 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5122 title_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
|
5123 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
|
5124 } |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5125 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5126 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5127 void |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5128 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
|
5129 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5130 if (elem_type == "xlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5131 update_xlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5132 else if (elem_type == "ylabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5133 update_ylabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5134 else if (elem_type == "zlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5135 update_zlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5136 else if (elem_type == "title") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5137 update_title_position (); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5138 else if (elem_type == "sync") |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5139 sync_positions (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5140 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5141 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5142 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5143 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5144 double xlength, double ylength, double zlength) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5145 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5146 double xval = xlength/scalefactors(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5147 double yval = ylength/scalefactors(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5148 double zval = zlength/scalefactors(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5149 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5150 double minval = xmin (xmin (xval, yval), zval); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5151 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5152 aspectratios(0) = xval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5153 aspectratios(1) = yval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5154 aspectratios(2) = zval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5155 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5156 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5157 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5158 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
|
5159 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
|
5160 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5161 if (tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5162 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5163 double minval = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5164 double maxval = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5165 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5166 double max_neg = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5167 get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type); |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5168 if (!xisinf (minval) && !xisnan (minval) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5169 && !xisinf (maxval) && !xisnan (maxval)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5170 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5171 limits(0) = minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5172 limits(1) = maxval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5173 s = xmax(s, (maxval - minval) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5174 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5175 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5176 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5177 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
|
5178 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5179 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5180 static bool updating_aspectratios = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5181 |
7427 | 5182 void |
5183 axes::properties::update_aspectratios (void) | |
5184 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5185 if (updating_aspectratios) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5186 return; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5187 |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5188 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
|
5189 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
|
5190 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
|
5191 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5192 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
|
5193 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
|
5194 double dz = (zlimits(1)-zlimits(0)); |
7427 | 5195 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5196 Matrix da = get_dataaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5197 Matrix pba = get_plotboxaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5198 |
7427 | 5199 if (dataaspectratiomode_is ("auto")) |
5200 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5201 if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5202 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5203 pba = Matrix (1, 3, 1.0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5204 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5205 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5206 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5207 normalized_aspectratios (da, pba, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5208 dataaspectratio.set (da, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5209 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5210 else if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5211 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5212 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5213 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5214 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5215 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5216 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5217 double s = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5218 bool modified_limits = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5219 Matrix kids; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5220 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5221 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
|
5222 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5223 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5224 kids = get_children (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5225 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
|
5226 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
|
5227 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
|
5228 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5229 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
|
5230 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5231 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5232 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
|
5233 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5234 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
|
5235 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5236 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5237 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
|
5238 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5239 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
|
5240 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5241 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5242 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
|
5243 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5244 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5245 if (modified_limits) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5246 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5247 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5248 unwind_protect frame; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5249 frame.protect_var (updating_aspectratios); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5250 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5251 updating_aspectratios = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5252 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5253 dx = pba(0) *da(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5254 dy = pba(1) *da(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5255 dz = pba(2) *da(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5256 if (xisinf (s)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5257 s = 1 / xmin (xmin (dx, dy), dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5258 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5259 if (xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5260 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5261 dx = s * dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5262 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
|
5263 xlimits(1) = xlimits(0) + dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5264 set_xlim (xlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5265 set_xlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5266 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5267 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5268 if (ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5269 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5270 dy = s * dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5271 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
|
5272 ylimits(1) = ylimits(0) + dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5273 set_ylim (ylimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5274 set_ylimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5275 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5276 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5277 if (zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5278 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5279 dz = s * dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5280 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
|
5281 zlimits(1) = zlimits(0) + dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5282 set_zlim (zlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5283 set_zlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5284 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5285 } |
7427 | 5286 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5287 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5288 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5289 plotboxaspectratio.set (pba, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5290 } |
7427 | 5291 } |
5292 } | |
5293 | |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5294 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5295 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
|
5296 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5297 #ifdef HAVE_FREETYPE |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5298 #ifdef HAVE_FONTCONFIG |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5299 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
|
5300 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
|
5301 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
|
5302 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
|
5303 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5304 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5305 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5306 |
7447 | 5307 // The INTERNAL flag defines whether position or outerposition is used. |
5308 | |
7427 | 5309 Matrix |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5310 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
|
5311 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
|
5312 { |
7447 | 5313 Matrix pos = (internal ? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5314 get_position ().matrix_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5315 : 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
|
5316 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
|
5317 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5318 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
|
5319 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5320 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
|
5321 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5322 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5323 obj.get_properties ().get_boundingbox (true).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
|
5324 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5325 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5326 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
|
5327 |
7427 | 5328 pos(0)--; |
5329 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
|
5330 pos(1) = parent_size(1) - pos(1) - pos(3); |
7427 | 5331 |
5332 return pos; | |
5333 } | |
5334 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5335 Matrix |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5336 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
|
5337 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5338 graphics_xform xform = get_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5339 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5340 Matrix ext (1, 4, 0.0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5341 ext(0) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5342 ext(1) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5343 ext(2) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5344 ext(3) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5345 for (int i = 0; i <= 1; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5346 for (int j = 0; j <= 1; j++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5347 for (int k = 0; k <= 1; k++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5348 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5349 ColumnVector p = xform.transform (i ? xPlaneN : xPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5350 j ? yPlaneN : yPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5351 k ? zPlaneN : zPlane, false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5352 ext(0) = std::min (ext(0), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5353 ext(1) = std::min (ext(1), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5354 ext(2) = std::max (ext(2), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5355 ext(3) = std::max (ext(3), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5356 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5357 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5358 if (with_text) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5359 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5360 for (int i = 0; i < 4; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5361 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5362 graphics_handle text_handle; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5363 if (i == 0) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5364 text_handle = get_title (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5365 else if (i == 1) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5366 text_handle = get_xlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5367 else if (i == 2) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5368 text_handle = get_ylabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5369 else if (i == 3) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5370 text_handle = get_zlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5371 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5372 text::properties& text_props = reinterpret_cast<text::properties&> |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5373 (gh_manager::get_object (text_handle).get_properties ()); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5374 |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5375 Matrix text_pos = text_props.get_position ().matrix_value (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5376 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
|
5377 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
|
5378 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5379 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
|
5380 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
|
5381 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
|
5382 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
|
5383 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5384 else |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5385 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5386 Matrix text_ext = text_props.get_extent_matrix (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5387 |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5388 bool ignore_horizontal = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5389 bool ignore_vertical = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5390 if (only_text_height) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5391 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5392 double text_rotation = text_props.get_rotation(); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5393 if (text_rotation == 0. || text_rotation == 180.) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5394 ignore_horizontal = true; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5395 else if (text_rotation == 90. || text_rotation == 270.) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5396 ignore_vertical = true; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5397 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5398 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5399 if (! ignore_horizontal) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5400 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5401 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5402 ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5403 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5404 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5405 if (! ignore_vertical) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5406 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5407 ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5408 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
|
5409 } |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5410 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5411 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5412 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5413 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5414 ext(2) = ext(2)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5415 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
|
5416 |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5417 return ext; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5418 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5419 |
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
|
5420 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
|
5421 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
|
5422 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5423 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
|
5424 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5425 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
|
5426 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
|
5427 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5428 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
|
5429 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
|
5430 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5431 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5432 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5433 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5434 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
|
5435 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
|
5436 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5437 graphics_object obj = gh_manager::get_object (get_parent ()); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5438 Matrix parent_bb = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5439 caseless_str new_units = get_units (); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5440 position.set (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb)), false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5441 outerposition.set (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb)), false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5442 tightinset.set (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb)), 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
|
5443 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5444 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5445 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
|
5446 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
|
5447 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5448 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
|
5449 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5450 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
|
5451 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
|
5452 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5453 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
|
5454 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
|
5455 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5456 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5457 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5458 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5459 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
|
5460 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
|
5461 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5462 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
|
5463 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
|
5464 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
|
5465 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5466 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
|
5467 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5468 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
|
5469 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5470 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5471 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5472 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
|
5473 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5474 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
|
5475 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
|
5476 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5477 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
|
5478 parent_height = get_boundingbox (true).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5479 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5480 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
|
5481 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5482 |
7435 | 5483 ColumnVector |
5484 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 5485 { |
5486 return ::xform_vector (x, y, z); | |
5487 } | |
7435 | 5488 |
5489 Matrix | |
5490 graphics_xform::xform_eye (void) | |
7869 | 5491 { |
5492 return ::xform_matrix (); | |
5493 } | |
7435 | 5494 |
5495 ColumnVector | |
5496 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
|
5497 bool use_scale) const |
7435 | 5498 { |
5499 if (use_scale) | |
5500 { | |
5501 x = sx.scale (x); | |
5502 y = sy.scale (y); | |
5503 z = sz.scale (z); | |
5504 } | |
5505 | |
5506 return ::transform (xform, x, y, z); | |
5507 } | |
5508 | |
5509 ColumnVector | |
5510 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
|
5511 bool use_scale) const |
7435 | 5512 { |
5513 ColumnVector v = ::transform (xform_inv, x, y, z); | |
5514 | |
5515 if (use_scale) | |
5516 { | |
5517 v(0) = sx.unscale (v(0)); | |
5518 v(1) = sy.unscale (v(1)); | |
5519 v(2) = sz.unscale (v(2)); | |
5520 } | |
5521 | |
5522 return v; | |
5523 } | |
5524 | |
6836 | 5525 octave_value |
7189 | 5526 axes::get_default (const caseless_str& name) const |
6836 | 5527 { |
5528 octave_value retval = default_properties.lookup (name); | |
5529 | |
5530 if (retval.is_undefined ()) | |
5531 { | |
5532 graphics_handle parent = get_parent (); | |
5533 graphics_object parent_obj = gh_manager::get_object (parent); | |
5534 | |
5535 retval = parent_obj.get_default (name); | |
5536 } | |
5537 | |
5538 return retval; | |
5539 } | |
5540 | |
8333 | 5541 // FIXME -- remove. |
5542 // 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
|
5543 /* |
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
|
5544 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5545 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
|
5546 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5547 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
|
5548 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
5549 double val = data.min_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
|
5550 if (! (xisinf (val) || xisnan (val)) && val < min_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
|
5551 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
|
5552 val = data.max_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
|
5553 if (! (xisinf (val) || xisnan (val)) && val > max_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
|
5554 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
|
5555 val = data.min_pos (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
5556 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
5557 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5558 val = data.max_neg (); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5559 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5560 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
|
5561 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5562 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5563 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5564 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5565 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
|
5566 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5567 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
|
5568 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5569 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
|
5570 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5571 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
|
5572 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5573 if (! error_state && m.numel () == 4) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5574 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5575 double val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5576 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5577 val = m(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5578 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5579 min_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5580 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5581 val = m(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5582 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5583 max_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5584 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5585 val = m(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5586 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5587 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5588 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5589 val = m(3); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5590 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5591 max_neg = val; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5592 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5593 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5594 } |
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
|
5595 |
12508
919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents:
12506
diff
changeset
|
5596 // 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
|
5597 // integer. |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5598 |
7869 | 5599 static void |
5600 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
|
5601 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5602 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5603 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5604 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5605 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5606 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5607 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5608 { |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
5609 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
|
5610 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
|
5611 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5612 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5613 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5614 // 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
|
5615 // http://kurage.nimh.nih.gov/tomh/tics.py |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5616 // FIXME -- add log ticks |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5617 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5618 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5619 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
|
5620 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5621 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5622 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5623 // 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
|
5624 // 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
|
5625 // 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
|
5626 // 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
|
5627 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5628 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5629 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5630 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5631 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
|
5632 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5633 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
|
5634 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
|
5635 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
|
5636 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5637 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5638 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5639 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5640 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5641 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5642 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5643 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5644 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5645 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5646 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
|
5647 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5648 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5649 |
7222 | 5650 // Attempt to make "nice" limits from the actual max and min of the |
5651 // data. For log plots, we will also use the smallest strictly positive | |
5652 // value. | |
5653 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5654 Matrix |
7869 | 5655 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
|
5656 double min_pos, double max_neg, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5657 bool logscale) |
7222 | 5658 { |
5659 Matrix retval; | |
5660 | |
5661 double min_val = xmin; | |
5662 double max_val = xmax; | |
5663 | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5664 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
|
5665 { |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5666 retval = default_lim (logscale); |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5667 return retval; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5668 } |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5669 else if (! (xisinf (min_val) || xisinf (max_val))) |
7222 | 5670 { |
5671 if (logscale) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5672 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5673 if (xisinf (min_pos) && xisinf (max_neg)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5674 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5675 // 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
|
5676 // 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
|
5677 // Is there another way? |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5678 retval = default_lim (); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5679 retval(0) = pow (10., retval(0)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5680 retval(1) = pow (10., retval(1)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5681 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5682 } |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13736
diff
changeset
|
5683 if ((min_val <= 0 && max_val > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5684 { |
14062
5b49cafe0599
Use non-negative, non-positive with hyphens in error messages.
Rik <octave@nomad.inbox5.com>
parents:
14022
diff
changeset
|
5685 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
|
5686 min_val = min_pos; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5687 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5688 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5689 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5690 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5691 min_val *= 0.9; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5692 max_val *= 1.1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5693 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5694 if (min_val > 0) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5695 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5696 // Log plots with all positive data |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5697 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
|
5698 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
|
5699 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5700 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5701 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5702 // 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
|
5703 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
|
5704 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
|
5705 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5706 } |
7222 | 5707 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5708 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5709 if (min_val == 0 && max_val == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5710 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5711 min_val = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5712 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5713 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5714 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5715 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5716 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5717 min_val -= 0.1 * std::abs (min_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5718 max_val += 0.1 * std::abs (max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5719 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5720 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5721 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
|
5722 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
|
5723 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
|
5724 // Prevent round-off from cropping ticks |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5725 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
|
5726 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
|
5727 } |
7222 | 5728 } |
5729 | |
5730 retval.resize (1, 2); | |
5731 | |
14022
de90542b7afc
Return retval(1) before retval(0) to avoid re-sizing call on retval.
Rik <octave@nomad.inbox5.com>
parents:
14021
diff
changeset
|
5732 retval(1) = max_val; |
7222 | 5733 retval(0) = min_val; |
5734 | |
5735 return retval; | |
5736 } | |
5737 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5738 void |
7869 | 5739 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
|
5740 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
|
5741 array_property& mticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5742 bool limmode_is_auto, bool is_logscale) |
7446 | 5743 { |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5744 // FIXME -- add log ticks and lims |
7446 | 5745 |
5746 if (lims.get ().is_empty ()) | |
5747 return; | |
5748 | |
5749 double lo = (lims.get ().matrix_value ()) (0); | |
5750 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
|
5751 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
|
5752 double tmp; |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5753 // 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
|
5754 if (hi < lo) |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5755 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5756 tmp = hi; |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5757 hi = lo; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5758 lo = tmp; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5759 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5760 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5761 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5762 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5763 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5764 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5765 tmp = hi; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5766 hi = std::log10 (-lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5767 lo = std::log10 (-tmp); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5768 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5769 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5770 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5771 hi = std::log10 (hi); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5772 lo = std::log10 (lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5773 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5774 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5775 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5776 double tick_sep = calc_tick_sep (lo , hi); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5777 |
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
|
5778 if (is_logscale && ! (xisinf (hi) || xisinf (lo))) |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5779 { |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5780 // FIXME - what if (hi-lo) < tick_sep? |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5781 // ex: loglog ([1 1.1]) |
13109
8e61aa0fac77
src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents:
13106
diff
changeset
|
5782 tick_sep = std::max (tick_sep, 1.); |
8e61aa0fac77
src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents:
13106
diff
changeset
|
5783 tick_sep = std::ceil (tick_sep); |
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
|
5784 } |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5785 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
5786 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
|
5787 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
|
5788 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5789 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5790 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5791 // 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
|
5792 Matrix tmp_lims (1,2); |
12549
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5793 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
|
5794 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
|
5795 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5796 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5797 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5798 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
|
5799 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
|
5800 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
|
5801 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
|
5802 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5803 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5804 tmp = tmp_lims(0); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5805 tmp_lims(0) = -tmp_lims(1); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5806 tmp_lims(1) = -tmp; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5807 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5808 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5809 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5810 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5811 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5812 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
|
5813 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
|
5814 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5815 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
|
5816 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5817 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
|
5818 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5819 if (is_logscale && is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5820 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5821 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
|
5822 rev_ticks = -tmp_ticks; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5823 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
|
5824 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
|
5825 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5826 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5827 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
|
5828 |
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
|
5829 int n = is_logscale ? 8 : 4; |
12157
0b9c1a7e350a
fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents:
12126
diff
changeset
|
5830 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
|
5831 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5832 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
|
5833 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5834 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
|
5835 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
|
5836 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5837 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
|
5838 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5839 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5840 mticks = tmp_mticks; |
7446 | 5841 } |
5842 | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5843 void |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5844 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
|
5845 any_property& labels, bool logscale) |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5846 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5847 Matrix values = ticks.get ().matrix_value (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5848 Cell c (values.dims ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5849 std::ostringstream os; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5850 |
13211
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5851 if (logscale) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5852 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5853 double significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5854 double exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5855 double exp_max = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5856 double exp_min = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5857 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5858 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
|
5859 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5860 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
|
5861 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
|
5862 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5863 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5864 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
|
5865 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5866 if (values(i) < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5867 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
|
5868 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5869 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
|
5870 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
|
5871 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5872 os << significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5873 if (exponent < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5874 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5875 os << "e-"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5876 exponent = -exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5877 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5878 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5879 os << "e+"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5880 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
|
5881 os << "0"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5882 os << exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5883 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5884 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5885 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5886 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5887 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5888 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
|
5889 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5890 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5891 os << values(i); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5892 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5893 } |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5894 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5895 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5896 labels = c; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5897 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5898 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5899 Matrix |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5900 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
|
5901 const string_vector& ticklabels, |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5902 const Matrix& limits) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5903 { |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5904 #ifndef HAVE_FREETYPE |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5905 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
|
5906 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5907 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5908 Matrix ext (1, 2, 0.0); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5909 double wmax = 0., hmax = 0.; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5910 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
|
5911 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
|
5912 { |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5913 double val = ticks(i); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5914 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
|
5915 { |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5916 #ifdef HAVE_FREETYPE |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5917 ext = text_renderer.get_extent (ticklabels(i)); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5918 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
|
5919 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
|
5920 #else |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5921 //FIXME: find a better approximation |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5922 int len = ticklabels(i).length(); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5923 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
|
5924 hmax = fontsize; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5925 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5926 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5927 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5928 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5929 ext(0) = wmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5930 ext(1) = hmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5931 return ext; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5932 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5933 |
9455 | 5934 void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5935 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
|
5936 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5937 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
|
5938 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5939 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
|
5940 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5941 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
|
5942 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5943 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
|
5944 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
|
5945 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5946 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
|
5947 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5948 if (obj.is_xliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5949 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5950 octave_value lim = obj.get_xlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5951 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5952 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
|
5953 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5954 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5955 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5956 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5957 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
|
5958 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
|
5959 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5960 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
|
5961 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5962 if (obj.is_yliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5963 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5964 octave_value lim = obj.get_ylim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5965 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5966 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
|
5967 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5968 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5969 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5970 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5971 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
|
5972 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
|
5973 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5974 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
|
5975 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5976 if (obj.is_zliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5977 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5978 octave_value lim = obj.get_zlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5979 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5980 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
|
5981 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5982 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5983 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5984 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5985 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
|
5986 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
|
5987 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5988 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
|
5989 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5990 if (obj.is_climinclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5991 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5992 octave_value lim = obj.get_clim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5993 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5994 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
|
5995 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5996 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5997 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5998 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5999 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
|
6000 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
|
6001 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6002 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
|
6003 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6004 if (obj.is_aliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6005 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6006 octave_value lim = obj.get_alim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6007 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6008 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
|
6009 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6010 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6011 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6012 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6013 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6014 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6015 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6016 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6017 |
7222 | 6018 static bool updating_axis_limits = false; |
6019 | |
7214 | 6020 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6021 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
|
6022 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
|
6023 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6024 if (updating_axis_limits) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6025 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6026 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6027 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
|
6028 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6029 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
|
6030 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
|
6031 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6032 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
|
6033 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6034 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
|
6035 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6036 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6037 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6038 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6039 #define FIX_LIMITS \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6040 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
|
6041 { \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6042 val = limits(0); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6043 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6044 min_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6045 val = limits(1); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6046 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6047 max_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6048 val = limits(2); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6049 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6050 min_pos = val; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6051 val = limits(3); \ |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6052 if (! (xisinf (val) || xisnan (val))) \ |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6053 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
|
6054 } \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6055 else \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6056 { \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6057 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
|
6058 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
|
6059 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
|
6060 limits(2) = min_pos; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6061 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
|
6062 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6063 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6064 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
|
6065 || 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
|
6066 || axis_type == "xlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6067 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6068 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
|
6069 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6070 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
|
6071 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6072 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6073 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
|
6074 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6075 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
|
6076 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
|
6077 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
|
6078 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6079 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6080 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6081 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6082 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
|
6083 || 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
|
6084 || axis_type == "ylim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6085 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6086 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
|
6087 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6088 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
|
6089 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6090 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6091 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
|
6092 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6093 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
|
6094 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
|
6095 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
|
6096 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6097 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6098 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6099 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6100 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
|
6101 || 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
|
6102 || axis_type == "zlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6103 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6104 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
|
6105 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6106 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
|
6107 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6108 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6109 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
|
6110 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6111 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
|
6112 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
|
6113 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
|
6114 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6115 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6116 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6117 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6118 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
|
6119 || 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
|
6120 || axis_type == "clim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6121 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6122 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
|
6123 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6124 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
|
6125 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6126 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6127 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
|
6128 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6129 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
|
6130 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6131 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
|
6132 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6133 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6134 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6135 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6136 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6137 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6138 } |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6139 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6140 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
|
6141 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6142 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
|
6143 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
|
6144 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6145 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6146 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6147 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6148 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6149 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
|
6150 || 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
|
6151 || axis_type == "alim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6152 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6153 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
|
6154 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6155 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
|
6156 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6157 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6158 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
|
6159 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6160 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
|
6161 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6162 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
|
6163 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6164 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6165 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
|
6166 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
|
6167 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6168 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
|
6169 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6170 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
|
6171 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
|
6172 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6173 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6174 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6175 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6176 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6177 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6178 #undef FIX_LIMITS |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6179 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6180 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6181 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
|
6182 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6183 updating_axis_limits = true; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6184 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6185 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6186 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6187 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6188 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
|
6189 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
|
6190 xproperties.update_xlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6191 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6192 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6193 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6194 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
|
6195 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
|
6196 xproperties.update_ylim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6197 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6198 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6199 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6200 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
|
6201 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
|
6202 xproperties.update_zlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6203 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6204 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6205 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6206 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
|
6207 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
|
6208 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6209 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6210 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6211 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
|
6212 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
|
6213 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6214 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6215 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6216 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6217 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6218 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6219 xproperties.update_transform (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6220 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6221 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6222 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6223 void |
7222 | 6224 axes::update_axis_limits (const std::string& axis_type) |
7214 | 6225 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6226 if (updating_axis_limits || updating_aspectratios) |
7222 | 6227 return; |
6228 | |
6229 Matrix kids = xproperties.get_children (); | |
6230 | |
6231 double min_val = octave_Inf; | |
6232 double max_val = -octave_Inf; | |
6233 double min_pos = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6234 double max_neg = -octave_Inf; |
7222 | 6235 |
6236 char update_type = 0; | |
6237 | |
6238 Matrix limits; | |
6239 | |
6240 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
|
6241 || 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
|
6242 || axis_type == "xlim") |
7222 | 6243 { |
7363 | 6244 if (xproperties.xlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6245 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6246 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
|
6247 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6248 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
|
6249 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6250 xproperties.xscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6251 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6252 update_type = 'x'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6253 } |
7222 | 6254 } |
6255 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
|
6256 || axis_type == "ylimmode" || axis_type == "yliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6257 || axis_type == "ylim") |
7222 | 6258 { |
7363 | 6259 if (xproperties.ylimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6260 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6261 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
|
6262 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6263 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
|
6264 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6265 xproperties.yscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6266 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6267 update_type = 'y'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6268 } |
7222 | 6269 } |
6270 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
|
6271 || axis_type == "zlimmode" || axis_type == "zliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6272 || axis_type == "zlim") |
7222 | 6273 { |
7363 | 6274 if (xproperties.zlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6275 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6276 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
|
6277 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6278 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
|
6279 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6280 xproperties.zscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6281 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6282 update_type = 'z'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6283 } |
7222 | 6284 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6285 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
|
6286 || axis_type == "cdatamapping" || axis_type == "climinclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6287 || axis_type == "clim") |
7222 | 6288 { |
7363 | 6289 if (xproperties.climmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6290 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6291 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
|
6292 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6293 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6294 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6295 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6296 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6297 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6298 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6299 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6300 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6301 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6302 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6303 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6304 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6305 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6306 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6307 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6308 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6309 update_type = 'c'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6310 } |
7222 | 6311 |
6312 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6313 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
|
6314 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6315 || 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
|
6316 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6317 if (xproperties.alimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6318 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6319 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
|
6320 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6321 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6322 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6323 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6324 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6325 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6326 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6327 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6328 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6329 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6330 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6331 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6332 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6333 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6334 update_type = 'a'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6335 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6336 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6337 } |
7222 | 6338 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6339 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6340 frame.protect_var (updating_axis_limits); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6341 |
7222 | 6342 updating_axis_limits = true; |
6343 | |
6344 switch (update_type) | |
6345 { | |
6346 case 'x': | |
6347 xproperties.set_xlim (limits); | |
6348 xproperties.set_xlimmode ("auto"); | |
7446 | 6349 xproperties.update_xlim (); |
7222 | 6350 break; |
6351 | |
6352 case 'y': | |
6353 xproperties.set_ylim (limits); | |
6354 xproperties.set_ylimmode ("auto"); | |
7446 | 6355 xproperties.update_ylim (); |
7222 | 6356 break; |
6357 | |
6358 case 'z': | |
6359 xproperties.set_zlim (limits); | |
6360 xproperties.set_zlimmode ("auto"); | |
7446 | 6361 xproperties.update_zlim (); |
7222 | 6362 break; |
6363 | |
6364 case 'c': | |
6365 xproperties.set_clim (limits); | |
6366 xproperties.set_climmode ("auto"); | |
6367 break; | |
6368 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6369 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
|
6370 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
|
6371 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
|
6372 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6373 |
7222 | 6374 default: |
6375 break; | |
6376 } | |
6377 | |
7427 | 6378 xproperties.update_transform (); |
7214 | 6379 } |
6380 | |
9455 | 6381 inline |
6382 double force_in_range (const double x, const double lower, const double upper) | |
6383 { | |
6384 if (x < lower) | |
6385 { return lower; } | |
6386 else if (x > upper) | |
6387 { return upper; } | |
6388 else | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6389 { return x; } |
9455 | 6390 } |
6391 | |
14311
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6392 static Matrix |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6393 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
|
6394 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6395 Matrix new_lims = lims; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6396 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6397 double lo = lims(0); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6398 double hi = lims(1); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6399 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6400 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
|
6401 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6402 if (is_logscale) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6403 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6404 if (is_negative) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6405 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6406 double tmp = hi; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6407 hi = std::log10 (-lo); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6408 lo = std::log10 (-tmp); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6409 val = std::log10 (-val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6410 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6411 else |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6412 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6413 hi = std::log10 (hi); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6414 lo = std::log10 (lo); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6415 val = std::log10 (val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6416 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6417 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6418 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6419 // Perform the zooming |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6420 lo = val + factor * (lo - val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6421 hi = val + factor * (hi - val); |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6422 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6423 if (is_logscale) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6424 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6425 if (is_negative) |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6426 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6427 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
|
6428 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
|
6429 lo = tmp; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6430 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6431 else |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6432 { |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6433 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
|
6434 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
|
6435 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6436 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6437 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6438 new_lims(0) = lo; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6439 new_lims(1) = hi; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6440 |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6441 return new_lims; |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6442 } |
d4f37aa5d126
fix zooming for logscale figures with fltk+opengl
John W. Eaton <jwe@octave.org>
parents:
14138
diff
changeset
|
6443 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6444 void |
9455 | 6445 axes::properties::zoom_about_point (double x, double y, double factor, |
6446 bool push_to_zoom_stack) | |
6447 { | |
6448 // FIXME: Do we need error checking here? | |
6449 Matrix xlims = get_xlim ().matrix_value (); | |
6450 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6451 |
9455 | 6452 // Get children axes limits |
6453 Matrix kids = get_children (); | |
6454 double minx = octave_Inf; | |
6455 double maxx = -octave_Inf; | |
6456 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
|
6457 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6458 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x'); |
9455 | 6459 |
6460 double miny = octave_Inf; | |
6461 double maxy = -octave_Inf; | |
6462 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
|
6463 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6464 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
|
6465 |
14325
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6466 if (! (xscale_is ("log") && xlims(0) < 0 && xlims(1) < 0)) |
14322
45f5a5d5656f
disable zooming for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14321
diff
changeset
|
6467 xlims = do_zoom (x, factor, xlims, xscale_is ("log")); |
45f5a5d5656f
disable zooming for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14321
diff
changeset
|
6468 |
14325
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6469 if (! (yscale_is ("log") && ylims(0) < 0 && ylims(1) < 0)) |
14322
45f5a5d5656f
disable zooming for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14321
diff
changeset
|
6470 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
|
6471 |
9455 | 6472 zoom (xlims, ylims, push_to_zoom_stack); |
6473 } | |
6474 | |
6475 void | |
6476 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack) | |
6477 { | |
14325
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6478 // FIXME: Do we need error checking here? |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6479 Matrix xlims = get_xlim ().matrix_value (); |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6480 Matrix ylims = get_ylim ().matrix_value (); |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6481 |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6482 if ((xscale_is ("log") && xlims(0) < 0 && xlims(1) < 0) |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6483 || (yscale_is ("log") && ylims(0) < 0 && ylims(1) < 0)) |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6484 return; |
a646cee995cf
disable zoom-box zooming for negative log scales; enable zooming for positive log scales
John W. Eaton <jwe@octave.org>
parents:
14322
diff
changeset
|
6485 |
9455 | 6486 if (push_to_zoom_stack) |
6487 { | |
6488 zoom_stack.push_front (xlimmode.get ()); | |
6489 zoom_stack.push_front (xlim.get ()); | |
6490 zoom_stack.push_front (ylimmode.get ()); | |
6491 zoom_stack.push_front (ylim.get ()); | |
6492 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6493 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6494 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6495 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6496 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6497 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6498 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6499 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6500 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6501 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6502 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6503 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6504 void |
9455 | 6505 axes::properties::translate_view (double delta_x, double delta_y) |
6506 { | |
6507 // FIXME: Do we need error checking here? | |
6508 Matrix xlims = get_xlim ().matrix_value (); | |
6509 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6510 |
9455 | 6511 // Get children axes limits |
6512 Matrix kids = get_children (); | |
6513 double minx = octave_Inf; | |
6514 double maxx = -octave_Inf; | |
6515 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
|
6516 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6517 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
|
6518 |
9455 | 6519 double miny = octave_Inf; |
6520 double maxy = -octave_Inf; | |
6521 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
|
6522 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6523 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
|
6524 |
14312
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6525 if (! xscale_is ("log")) |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6526 { |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6527 xlims (0) += delta_x; |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6528 xlims (1) += delta_x; |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6529 } |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6530 |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6531 if (! yscale_is ("log")) |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6532 { |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6533 ylims (0) += delta_y; |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6534 ylims (1) += delta_y; |
1734c3a48f31
disable panning for logscale axes
John W. Eaton <jwe@octave.org>
parents:
14311
diff
changeset
|
6535 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6536 |
9455 | 6537 zoom (xlims, ylims, false); |
6538 } | |
6539 | |
6540 void | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6541 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
|
6542 { |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6543 Matrix v = get_view ().matrix_value (); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6544 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6545 v (1) += delta_el; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6546 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6547 if(v(1) > 90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6548 v(1) = 90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6549 if(v(1) < -90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6550 v(1) = -90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6551 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6552 v (0) = fmod(v(0) - delta_az + 720,360); |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6553 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6554 set_view(v); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6555 update_transform(); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6556 } |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6557 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6558 void |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6559 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6560 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6561 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6562 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6563 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6564 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6565 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6566 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6567 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6568 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6569 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6570 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6571 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6572 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6573 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6574 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6575 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6576 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6577 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6578 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6579 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6580 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6581 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6582 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6583 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6584 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6585 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6586 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6587 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6588 axes::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6589 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
6590 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6591 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6592 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6593 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6594 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
|
6595 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6596 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
|
6597 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6598 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
|
6599 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
|
6600 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
|
6601 xinitialize (xproperties.get_zlabel ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6602 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6603 |
7363 | 6604 // --------------------------------------------------------------------- |
6605 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6606 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6607 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
|
6608 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6609 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
|
6610 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6611 m(0) = xdata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6612 m(1) = xdata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6613 m(2) = xdata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6614 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
|
6615 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6616 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
|
6617 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6618 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6619 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6620 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
|
6621 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6622 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
|
6623 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6624 m(0) = ydata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6625 m(1) = ydata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6626 m(2) = ydata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6627 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
|
6628 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6629 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
|
6630 } |
6406 | 6631 |
6632 // --------------------------------------------------------------------- | |
6633 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6634 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6635 text::properties::get_data_position (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6636 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6637 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6638 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6639 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6640 pos = convert_text_position (pos, *this, get_units (), "data"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6641 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6642 return pos; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6643 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6644 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6645 Matrix |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6646 text::properties::get_extent_matrix (void) const |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6647 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6648 return extent.get ().matrix_value (); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6649 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6650 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6651 octave_value |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6652 text::properties::get_extent (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6653 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6654 Matrix m = extent.get ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6655 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6656 return convert_text_position (m, *this, "pixels", get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6657 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6658 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6659 void |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6660 text::properties::update_font (void) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6661 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6662 #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
|
6663 #ifdef HAVE_FONTCONFIG |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6664 renderer.set_font (get ("fontname").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6665 get ("fontweight").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6666 get ("fontangle").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6667 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
|
6668 #endif |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6669 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
|
6670 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6671 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6672 |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6673 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6674 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
|
6675 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6676 #ifdef HAVE_FREETYPE |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6677 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6678 int halign = 0, valign = 0; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6679 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6680 if (horizontalalignment_is ("center")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6681 halign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6682 else if (horizontalalignment_is ("right")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6683 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6684 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6685 if (verticalalignment_is ("top")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6686 valign = 2; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6687 else if (verticalalignment_is ("baseline")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6688 valign = 3; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6689 else if (verticalalignment_is ("middle")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6690 valign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6691 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6692 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
|
6693 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6694 // 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
|
6695 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6696 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
|
6697 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6698 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
|
6699 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6700 renderer.text_to_pixels (sv.join ("\n"), pixels, bbox, |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6701 halign, valign, get_rotation ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6702 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
|
6703 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6704 #endif |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6705 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6706 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
|
6707 autopos_tag_is ("zlabel") || autopos_tag_is ("title")) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6708 update_autopos ("sync"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6709 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6710 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6711 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6712 text::properties::request_autopos (void) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6713 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6714 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
|
6715 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
|
6716 update_autopos (get_autopos_tag ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6717 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6718 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6719 void |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6720 text::properties::update_units (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6721 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6722 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6723 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6724 set_xliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6725 set_yliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6726 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6727 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6728 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6729 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6730 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6731 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
|
6732 // 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
|
6733 // 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
|
6734 // to "off". |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6735 set_position (pos); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6736 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6737 if (units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6738 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6739 set_xliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6740 set_yliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6741 // FIXME: see above |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6742 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6743 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6744 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6745 cached_units = get_units (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6746 } |
6406 | 6747 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6748 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6749 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
|
6750 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6751 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
|
6752 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
|
6753 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6754 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
|
6755 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6756 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
|
6757 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
|
6758 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6759 parent_height = ax.get_properties ().get_boundingbox (true).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6760 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6761 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6762 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
|
6763 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6764 |
6406 | 6765 // --------------------------------------------------------------------- |
6766 | |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6767 octave_value |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6768 image::properties::get_color_data (void) const |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6769 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6770 return convert_cdata (*this, get_cdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6771 cdatamapping_is ("scaled"), 3); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6772 } |
6406 | 6773 |
6774 // --------------------------------------------------------------------- | |
6775 | |
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
|
6776 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
|
6777 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
|
6778 { |
11168
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6779 octave_value fvc = get_facevertexcdata(); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6780 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
|
6781 return Matrix (); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6782 else |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6783 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
|
6784 } |
6807 | 6785 |
6786 // --------------------------------------------------------------------- | |
6787 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6788 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6789 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
|
6790 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6791 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
|
6792 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6793 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6794 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6795 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
|
6796 double x2, double y2, double z2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6797 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
|
6798 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6799 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
|
6800 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
|
6801 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
|
6802 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6803 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6804 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6805 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
|
6806 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6807 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6808 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6809 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
|
6810 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
|
6811 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
|
6812 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6813 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6814 int p = z.columns (), q = z.rows (); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6815 int i1 = 0, i2 = 0, i3 = 0; |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6816 int j1 = 0, j2 = 0, j3 = 0; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6817 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6818 bool x_mat = (x.rows () == q); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6819 bool y_mat = (y.columns () == p); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6820 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6821 NDArray n (dim_vector (q, p, 3), 0.0); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6822 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6823 for (int i = 0; i < p; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6824 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6825 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6826 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6827 i1 = i - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6828 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6829 i3 = i + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6830 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6831 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6832 for (int j = 0; j < q; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6833 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6834 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6835 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6836 j1 = j - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6837 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6838 j3 = j + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6839 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6840 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6841 double& nx = n(j, i, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6842 double& ny = n(j, i, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6843 double& nz = n(j, i, 2); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6844 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6845 if ((j > 0) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6846 // upper left quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6847 cross_product (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6848 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6849 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6850 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6851 if ((j > 0) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6852 // upper right quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6853 cross_product (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6854 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6855 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6856 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6857 if ((j < (q - 1)) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6858 // lower left quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6859 cross_product (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6860 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6861 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6862 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6863 if ((j < (q - 1)) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6864 // lower right quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6865 cross_product (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1), |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6866 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6867 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6868 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
6869 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
|
6870 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6871 nx /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6872 ny /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6873 nz /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6874 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6875 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6876 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6877 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6878 } |
6406 | 6879 |
6880 // --------------------------------------------------------------------- | |
6881 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6882 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6883 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
|
6884 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6885 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
|
6886 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6887 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6888 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6889 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
|
6890 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
|
6891 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
|
6892 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
|
6893 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
|
6894 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6895 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6896 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6897 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6898 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
|
6899 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6900 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
|
6901 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6902 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6903 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6904 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
|
6905 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
|
6906 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
|
6907 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
|
6908 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
|
6909 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6910 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6911 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6912 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
|
6913 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6914 void |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6915 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
|
6916 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
|
6917 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6918 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
|
6919 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6920 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6921 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
|
6922 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6923 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
|
6924 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
|
6925 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6926 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
|
6927 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6928 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6929 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6930 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6931 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
|
6932 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6933 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
|
6934 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6935 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
|
6936 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6937 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6938 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
|
6939 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6940 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
|
6941 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6942 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6943 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
|
6944 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6945 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
|
6946 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6947 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6948 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
|
6949 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6950 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
|
6951 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6952 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6953 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
|
6954 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6955 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
|
6956 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6957 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6958 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6959 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
|
6960 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6961 val = limits(0); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6962 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6963 min_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6964 val = limits(1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6965 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6966 max_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6967 val = limits(2); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6968 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6969 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6970 val = limits(3); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6971 if (! (xisinf (val) || xisnan (val))) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6972 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
|
6973 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6974 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6975 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6976 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
|
6977 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
|
6978 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
|
6979 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6980 limits(3) = max_neg; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6981 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6982 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6983 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
|
6984 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6985 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6986 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
|
6987 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6988 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
|
6989 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6990 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
|
6991 || 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
|
6992 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6993 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
|
6994 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
|
6995 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6996 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
|
6997 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6998 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6999 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7000 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7001 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
|
7002 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7003 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7004 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7005 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
|
7006 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7007 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7008 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7009 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
|
7010 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7011 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7012 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7013 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
|
7014 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7015 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7016 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7017 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
|
7018 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7019 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7020 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7021 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7022 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7023 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7024 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
|
7025 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7026 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7027 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7028 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7029 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7030 { |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7031 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
|
7032 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7033 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7034 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7035 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7036 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7037 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7038 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7039 double max_neg = -octave_Inf; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7040 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7041 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7042 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
7043 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7044 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7045 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
|
7046 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7047 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7048 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
7049 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7050 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7051 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
|
7052 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7053 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7054 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
7055 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7056 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7057 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
|
7058 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7059 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7060 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
7061 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7062 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7063 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
|
7064 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7065 update_type = 'c'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7066 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
7067 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7068 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7069 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
|
7070 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7071 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7072 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7073 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7074 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7075 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
|
7076 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
7077 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
|
7078 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7079 Matrix limits (1, 4, 0.0); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7080 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7081 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7082 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7083 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
7084 limits(3) = max_neg; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7085 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7086 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7087 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7088 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7089 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7090 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7091 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7092 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7093 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7094 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7095 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7096 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7097 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7098 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7099 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7100 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7101 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7102 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7103 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7104 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7105 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7106 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7107 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7108 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7109 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7110 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7111 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7112 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7113 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7114 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7115 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7116 |
6406 | 7117 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
|
7118 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
|
7119 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7120 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
|
7121 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7122 graphics_object parent_obj = |
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7123 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
|
7124 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
|
7125 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
|
7126 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7127 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
|
7128 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7129 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7130 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7131 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
|
7132 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7133 #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
|
7134 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7135 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
|
7136 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
|
7137 Matrix box; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7138 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7139 // 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
|
7140 // FIXME: support multiline text |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7141 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7142 elt = text_parser_none ().parse (get_string_string ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7143 #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
|
7144 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
|
7145 get_fontweight (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7146 get_fontangle (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7147 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
|
7148 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7149 box = text_renderer.get_extent (elt, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7150 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7151 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
|
7152 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7153 // 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
|
7154 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7155 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
|
7156 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
|
7157 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
|
7158 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7159 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
|
7160 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7161 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7162 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7163 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7164 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7165 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
|
7166 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7167 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
|
7168 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7169 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
|
7170 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
|
7171 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7172 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7173 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
|
7174 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
|
7175 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7176 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
|
7177 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7178 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7179 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7180 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
|
7181 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7182 if (get___object__ ().is_empty()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7183 style = st; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7184 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7185 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
|
7186 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7187 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7188 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7189 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
|
7190 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
|
7191 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7192 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
|
7193 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
|
7194 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7195 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
|
7196 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7197 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
|
7198 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7199 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7200 obj.get_properties ().get_boundingbox (true).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
|
7201 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7202 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7203 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
|
7204 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7205 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7206 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7207 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
|
7208 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7209 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7210 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7211 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7212 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7213 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
|
7214 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7215 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
|
7216 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7217 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
|
7218 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
|
7219 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7220 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
|
7221 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7222 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7223 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7224 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7225 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7226 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7227 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
|
7228 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7229 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
|
7230 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
|
7231 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
|
7232 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7233 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
|
7234 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7235 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
|
7236 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7237 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7238 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7239 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
|
7240 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7241 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
|
7242 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
|
7243 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7244 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
|
7245 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
|
7246 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7247 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
|
7248 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7249 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7250 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7251 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7252 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7253 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
|
7254 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
|
7255 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7256 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
|
7257 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
|
7258 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7259 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
|
7260 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7261 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
|
7262 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7263 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7264 obj.get_properties ().get_boundingbox (true).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
|
7265 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7266 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7267 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
|
7268 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7269 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7270 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7271 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
|
7272 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7273 if (internal) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7274 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7275 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
|
7276 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7277 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
|
7278 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7279 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
|
7280 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7281 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
|
7282 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
|
7283 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7284 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
|
7285 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
|
7286 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7287 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
|
7288 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
|
7289 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
|
7290 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
|
7291 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7292 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7293 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
|
7294 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7295 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
|
7296 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7297 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
|
7298 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7299 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
|
7300 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7301 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
|
7302 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
|
7303 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
|
7304 fs *= res; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7305 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
|
7306 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
|
7307 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
|
7308 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
|
7309 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7310 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7311 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
|
7312 || 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
|
7313 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
|
7314 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
|
7315 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7316 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7317 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7318 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7319 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7320 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7321 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7322 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
|
7323 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7324 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
|
7325 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7326 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
|
7327 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
|
7328 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7329 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
|
7330 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7331 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7332 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7333 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7334 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7335 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7336 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
|
7337 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7338 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
|
7339 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7340 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
|
7341 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
|
7342 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7343 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7344 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
|
7345 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
|
7346 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7347 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7348 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7349 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
|
7350 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7351 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
|
7352 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7353 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
|
7354 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
|
7355 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7356 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
|
7357 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7358 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7359 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7360 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7361 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7362 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7363 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
|
7364 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7365 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
|
7366 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
|
7367 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
|
7368 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7369 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
|
7370 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7371 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
|
7372 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7373 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7374 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7375 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
|
7376 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7377 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
|
7378 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
|
7379 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7380 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
|
7381 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
|
7382 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7383 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
|
7384 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7385 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7386 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7387 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7388 octave_value |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7389 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
|
7390 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7391 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
|
7392 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7393 if (retval.is_undefined ()) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7394 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7395 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
|
7396 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
|
7397 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7398 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
|
7399 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7400 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7401 return retval; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7402 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7403 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7404 void |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7405 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
|
7406 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7407 ::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
|
7408 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7409 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7410 // --------------------------------------------------------------------- |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7411 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7412 octave_value |
7189 | 7413 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 7414 { |
7415 graphics_handle parent = get_parent (); | |
7416 graphics_object parent_obj = gh_manager::get_object (parent); | |
7417 | |
7418 return parent_obj.get_default (type () + name); | |
7419 } | |
7420 | |
7421 octave_value | |
7189 | 7422 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 7423 { |
7424 graphics_object parent_obj = gh_manager::get_object (0); | |
7425 | |
7426 return parent_obj.get_factory_default (type () + name); | |
7427 } | |
7428 | |
7286 | 7429 // We use a random value for the handle to avoid issues with plots and |
7430 // scalar values for the first argument. | |
6406 | 7431 gh_manager::gh_manager (void) |
7286 | 7432 : handle_map (), handle_free_list (), |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7433 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
|
7434 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
|
7435 callback_objects (), event_processing (0) |
6406 | 7436 { |
7437 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
7438 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7439 // 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
|
7440 gtk_manager::default_toolkit (); |
6406 | 7441 } |
7442 | |
13992
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7443 void |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7444 gh_manager::create_instance (void) |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7445 { |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7446 instance = new gh_manager (); |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7447 |
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
|
7448 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
|
7449 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
|
7450 } |
e1f76bfe0452
apply singleton_cleanup to a few more classes
John W. Eaton <jwe@octave.org>
parents:
13955
diff
changeset
|
7451 |
6406 | 7452 graphics_handle |
7453 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
|
7454 const graphics_handle& p, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
7455 bool integer_figure_handle, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
7456 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
|
7457 bool do_notify_toolkit) |
6406 | 7458 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
7459 graphics_handle h = get_handle (integer_figure_handle); |
6406 | 7460 |
7461 base_graphics_object *go = 0; | |
7462 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7463 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
|
7464 |
6406 | 7465 if (go) |
7370 | 7466 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7467 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7468 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7469 handle_map[h] = obj; |
7370 | 7470 if (do_createfcn) |
7471 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7472 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7473 // 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
|
7474 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
|
7475 obj.initialize (); |
7370 | 7476 } |
6406 | 7477 else |
7478 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
|
7479 go_name.c_str ()); |
6406 | 7480 |
7481 return h; | |
7482 } | |
7483 | |
7484 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
|
7485 gh_manager::do_make_figure_handle (double val, bool do_notify_toolkit) |
6406 | 7486 { |
7487 graphics_handle h = val; | |
7488 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7489 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
|
7490 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7491 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7492 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7493 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7494 // 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
|
7495 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
|
7496 obj.initialize (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7497 |
6406 | 7498 return h; |
7499 } | |
7500 | |
7501 void | |
7502 gh_manager::do_push_figure (const graphics_handle& h) | |
7503 { | |
7504 do_pop_figure (h); | |
7505 | |
7506 figure_list.push_front (h); | |
7507 } | |
7508 | |
7509 void | |
7510 gh_manager::do_pop_figure (const graphics_handle& h) | |
7511 { | |
7512 for (figure_list_iterator p = figure_list.begin (); | |
7513 p != figure_list.end (); | |
7514 p++) | |
7515 { | |
7516 if (*p == h) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7517 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7518 figure_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7519 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7520 } |
6406 | 7521 } |
7522 } | |
7523 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7524 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7525 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
|
7526 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7527 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7528 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
|
7529 const octave_value& data = Matrix ()) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7530 : base_graphics_event (), handle (h), callback_name (name), |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7531 callback (), callback_data (data) { } |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7532 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7533 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
|
7534 const octave_value& data = Matrix ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7535 : base_graphics_event (), handle (h), callback_name (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7536 callback (cb), callback_data (data) { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7537 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7538 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7539 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7540 if (callback.is_defined ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7541 gh_manager::execute_callback (handle, callback, callback_data); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7542 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7543 gh_manager::execute_callback (handle, callback_name, callback_data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7544 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7545 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7546 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7547 callback_event (void) |
12174 | 7548 : base_graphics_event (), handle (), |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7549 callback_name (), callback_data () |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7550 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7551 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7552 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7553 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7554 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
|
7555 octave_value callback; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7556 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7557 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7558 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7559 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7560 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
|
7561 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7562 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7563 function_event (graphics_event::event_fcn fcn, void* data = 0) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7564 : base_graphics_event (), function (fcn), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7565 function_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7566 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7567 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7568 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7569 function (function_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7570 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7571 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7572 private: |
12174 | 7573 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7574 graphics_event::event_fcn function; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7575 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7576 void* function_data; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7577 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7578 // 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
|
7579 function_event (void); |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7580 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7581 // No copying! |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7582 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7583 function_event (const function_event &); |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7584 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7585 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
|
7586 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7587 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7588 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7589 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
|
7590 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7591 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7592 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
|
7593 const octave_value& value, bool do_notify_toolkit = true) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7594 : base_graphics_event (), handle (h), property_name (name), |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7595 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
|
7596 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7597 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7598 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7599 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
|
7600 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7601 graphics_object go = gh_manager::get_object (handle); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7602 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7603 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7604 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7605 property p = go.get_properties ().get_property (property_name); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7606 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7607 if (p.ok ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7608 p.set (property_value, true, notify_toolkit); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7609 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7610 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7611 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7612 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7613 set_event (void) |
12174 | 7614 : base_graphics_event (), handle (), property_name (), property_value () |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7615 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7616 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7617 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7618 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7619 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7620 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
|
7621 bool notify_toolkit; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7622 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7623 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7624 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7625 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
|
7626 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7627 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7628 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7629 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7630 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7631 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
|
7632 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7633 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7634 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7635 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7636 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
|
7637 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
|
7638 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
|
7639 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
|
7640 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7641 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
|
7642 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7643 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
|
7644 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7645 return e; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7646 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7647 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7648 graphics_event |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7649 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
|
7650 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7651 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7652 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7653 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7654 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
|
7655 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7656 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7657 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7658 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7659 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7660 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
|
7661 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
|
7662 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
|
7663 bool notify_toolkit) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7664 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7665 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7666 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7667 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
|
7668 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7669 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7670 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7671 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7672 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7673 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7674 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7675 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
|
7676 root_figure::properties& props = |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7677 dynamic_cast<root_figure::properties&> (go.get_properties ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7678 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7679 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
|
7680 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7681 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7682 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7683 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7684 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7685 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7686 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7687 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7688 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7689 xset_gcbo (callback_objects.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7690 ? graphics_handle () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7691 : callback_objects.front ().get_handle ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7692 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7693 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7694 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7695 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
|
7696 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
|
7697 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7698 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
|
7699 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
|
7700 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7701 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7702 gh_manager::auto_lock guard; |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7703 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7704 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
|
7705 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7706 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7707 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7708 void |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7709 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
|
7710 const octave_value& cb_arg, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7711 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7712 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7713 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
|
7714 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7715 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
|
7716 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
|
7717 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7718 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
|
7719 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
|
7720 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
|
7721 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7722 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
|
7723 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7724 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
|
7725 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
|
7726 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7727 if (true) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7728 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7729 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
|
7730 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7731 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
|
7732 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
|
7733 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7734 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7735 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
|
7736 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7737 // 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
|
7738 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7739 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
|
7740 |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
7741 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
|
7742 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
|
7743 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
|
7744 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7745 int status; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7746 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
|
7747 |
13940
bf209050014f
Use nargout = 0 in graphics callbacks specified as string.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13935
diff
changeset
|
7748 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
|
7749 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7750 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
|
7751 && (cb.rows () == 1 || cb.columns () == 1) |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
7752 && (cb.cell_value ()(0).is_function () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
7753 || 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
|
7754 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7755 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
|
7756 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7757 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
|
7758 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
|
7759 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7760 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
|
7761 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
|
7762 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7763 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7764 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7765 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7766 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
|
7767 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
|
7768 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
|
7769 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7770 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7771 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
|
7772 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
|
7773 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7774 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
|
7775 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7776 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7777 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7778 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7779 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
|
7780 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7781 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7782 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7783 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
|
7784 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7785 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7786 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7787 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
|
7788 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7789 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7790 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7791 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7792 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7793 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7794 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7795 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7796 if (callback_objects.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7797 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
|
7798 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7799 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7800 const graphics_object& current = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7801 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7802 if (current.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7803 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7804 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7805 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7806 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
|
7807 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7808 if (busy_action.compare ("queue")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7809 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7810 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7811 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7812 caseless_str cname (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7813 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7814 if (cname.compare ("deletefcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7815 || cname.compare ("createfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7816 || (go.isa ("figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7817 && (cname.compare ("closerequestfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7818 || cname.compare ("resizefcn")))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7819 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7820 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7821 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7822 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7823 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7824 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7825 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7826 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7827 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
|
7828 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7829 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7830 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7831 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
|
7832 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7833 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7834 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7835 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
|
7836 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
|
7837 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7838 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
|
7839 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7840 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
|
7841 notify_toolkit)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7842 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7843 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7844 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7845 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
|
7846 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7847 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
|
7848 bool old_Vdrawnow_requested = Vdrawnow_requested; |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7849 bool events_executed = false; |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7850 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7851 do |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7852 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7853 e = graphics_event (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7854 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7855 gh_manager::lock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7856 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7857 if (! event_queue.empty ()) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7858 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7859 if (callback_objects.empty () || force) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7860 { |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7861 e = event_queue.front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7862 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7863 event_queue.pop_front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7864 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7865 else |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7866 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7867 const graphics_object& go = callback_objects.front (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7868 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7869 if (go.get_properties ().is_interruptible ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7870 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7871 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7872 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7873 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7874 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7875 } |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7876 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7877 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7878 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7879 |
13935
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7880 if (e.ok ()) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7881 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7882 e.execute (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7883 events_executed = true; |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7884 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7885 } |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7886 while (e.ok ()); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7887 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7888 gh_manager::lock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7889 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7890 if (event_queue.empty () && event_processing == 0) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7891 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
|
7892 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7893 gh_manager::unlock (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7894 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7895 if (events_executed) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7896 flush_octave_stdout (); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7897 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7898 if (Vdrawnow_requested && ! old_Vdrawnow_requested) |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7899 { |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7900 feval ("drawnow"); |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7901 |
e48e8253ce58
Re-allow recursive graphics event processing.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13929
diff
changeset
|
7902 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
|
7903 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7904 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7905 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7906 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7907 |
13908
32a77debff75
strip trailing spaces
Konstantinos Poulios <logari81@googlemail.com>
parents:
13897
diff
changeset
|
7908 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7909 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
|
7910 { |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7911 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
|
7912 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7913 if (enable) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7914 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7915 event_processing++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7916 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7917 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
|
7918 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7919 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7920 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7921 event_processing--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7922 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7923 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
|
7924 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
|
7925 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7926 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7927 |
6406 | 7928 property_list::plist_map_type |
7929 root_figure::init_factory_properties (void) | |
7930 { | |
7931 property_list::plist_map_type plist_map; | |
7932 | |
6844 | 7933 plist_map["figure"] = figure::properties::factory_defaults (); |
7934 plist_map["axes"] = axes::properties::factory_defaults (); | |
7935 plist_map["line"] = line::properties::factory_defaults (); | |
7936 plist_map["text"] = text::properties::factory_defaults (); | |
7937 plist_map["image"] = image::properties::factory_defaults (); | |
7938 plist_map["patch"] = patch::properties::factory_defaults (); | |
7939 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7940 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
|
7941 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
|
7942 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
|
7943 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
|
7944 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
|
7945 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
|
7946 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
|
7947 plist_map["uitoggletool"] = uitoggletool::properties::factory_defaults (); |
6406 | 7948 |
7949 return plist_map; | |
7950 } | |
7951 | |
7952 // --------------------------------------------------------------------- | |
7953 | |
7954 DEFUN (ishandle, args, , | |
7955 "-*- texinfo -*-\n\ | |
6678 | 7956 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 7957 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7958 @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
|
7959 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
|
7960 graphics handles and false where they are not.\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7961 @seealso{isfigure}\n\ |
6406 | 7962 @end deftypefn") |
7963 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7964 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7965 |
6406 | 7966 octave_value retval; |
7967 | |
7968 if (args.length () == 1) | |
7969 retval = is_handle (args(0)); | |
7970 else | |
7971 print_usage (); | |
7972 | |
7973 return retval; | |
7974 } | |
7975 | |
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
|
7976 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
|
7977 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
|
7978 { |
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
|
7979 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
|
7980 } |
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
|
7981 |
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
|
7982 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
|
7983 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
|
7984 { |
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
|
7985 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
|
7986 } |
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
|
7987 |
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
|
7988 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
|
7989 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
|
7990 { |
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
|
7991 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
|
7992 |
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
|
7993 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
|
7994 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
|
7995 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
|
7996 { |
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
|
7997 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
|
7998 |
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
|
7999 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
|
8000 { |
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
|
8001 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
|
8002 |
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
|
8003 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
|
8004 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
|
8005 |
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
|
8006 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
|
8007 } |
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
|
8008 } |
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
|
8009 |
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
|
8010 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
|
8011 } |
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
|
8012 |
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
|
8013 DEFUN (__is_handle_visible__, args, , |
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
|
8014 "-*- texinfo -*-\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
|
8015 @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
|
8016 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
|
8017 @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
|
8018 { |
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
|
8019 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
|
8020 |
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
|
8021 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
|
8022 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
|
8023 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
|
8024 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
|
8025 |
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
|
8026 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
|
8027 } |
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
|
8028 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8029 DEFUN (reset, args, , |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8030 "-*- texinfo -*-\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8031 @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
|
8032 Remove any defaults set for the handle @var{h}. The default figure\n\ |
12189
9558ca33648d
Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
8033 properties of \"position\", \"units\", \"windowstyle\" and\n\ |
9558ca33648d
Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
8034 \"paperunits\" and the default axes properties of \"position\" and \"units\"\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8035 are not reset.\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8036 @end deftypefn") |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8037 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8038 int nargin = args.length (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8039 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8040 if (nargin != 1) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8041 print_usage (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8042 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8043 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8044 // get vector of graphics handles |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8045 ColumnVector hcv (args(0).vector_value ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8046 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8047 if (! error_state) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8048 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8049 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8050 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
|
8051 gh_manager::get_object (hcv(n)).reset_default_properties (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8052 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8053 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8054 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8055 return octave_value (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8056 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
8057 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8058 DEFUN (set, args, nargout, |
6406 | 8059 "-*- texinfo -*-\n\ |
10840 | 8060 @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
|
8061 @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
|
8062 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8063 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
|
8064 handles) @var{h}.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8065 There are three ways how to give the property names and values:\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8066 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8067 @itemize\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8068 @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
|
8069 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8070 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
|
8071 @var{value} is a value of the appropriate type for the property.\n\ |
10840 | 8072 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8073 @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
|
8074 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
|
8075 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8076 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
|
8077 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
|
8078 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
|
8079 @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
|
8080 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
|
8081 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
|
8082 the first row of @var{values} and so on.\n\ |
10840 | 8083 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8084 @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
|
8085 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8086 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
|
8087 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
|
8088 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
|
8089 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
|
8090 @end itemize\n\ |
6406 | 8091 @end deftypefn") |
8092 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8093 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8094 |
6406 | 8095 octave_value retval; |
8096 | |
8097 int nargin = args.length (); | |
8098 | |
8099 if (nargin > 0) | |
8100 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8101 // get vector of graphics handles |
6732 | 8102 ColumnVector hcv (args(0).vector_value ()); |
6406 | 8103 |
8104 if (! error_state) | |
6732 | 8105 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8106 bool request_drawnow = false; |
6733 | 8107 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8108 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8109 for (octave_idx_type n = 0; n < hcv.length (); n++) |
6732 | 8110 { |
8111 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 8112 |
6732 | 8113 if (obj) |
8114 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8115 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
|
8116 && args(2).is_cell ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8117 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8118 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
|
8119 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8120 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
|
8121 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
|
8122 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8123 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
|
8124 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8125 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
|
8126 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
|
8127 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8128 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8129 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8130 error("set: number of graphics handles must match number of value rows (%d != %d)", |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8131 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
|
8132 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8133 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8134 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8135 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8136 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
|
8137 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8138 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
|
8139 } |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8140 else if (nargin == 1) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8141 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8142 if (nargout != 0) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8143 retval = obj.values_as_struct (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8144 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8145 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8146 std::string s = obj.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8147 if (! error_state) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8148 octave_stdout << s; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8149 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
8150 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8151 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8152 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8153 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
|
8154 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8155 } |
6732 | 8156 } |
8157 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8158 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8159 error ("set: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8160 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8161 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8162 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8163 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8164 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8165 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8166 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
8167 } |
6733 | 8168 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8169 if (! error_state && request_drawnow) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8170 Vdrawnow_requested = true; |
6732 | 8171 } |
6406 | 8172 else |
6732 | 8173 error ("set: expecting graphics handle as first argument"); |
6406 | 8174 } |
8175 else | |
8176 print_usage (); | |
8177 | |
8178 return retval; | |
8179 } | |
8180 | |
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
|
8181 static std::string |
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
|
8182 get_graphics_object_type (const double 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
|
8183 { |
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
|
8184 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
|
8185 |
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
|
8186 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
|
8187 |
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
|
8188 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
|
8189 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
|
8190 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
|
8191 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
|
8192 |
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
|
8193 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
|
8194 } |
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
|
8195 |
6406 | 8196 DEFUN (get, args, , |
8197 "-*- texinfo -*-\n\ | |
6678 | 8198 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406 | 8199 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
8200 If @var{p} is omitted, return the complete property list for @var{h}.\n\ | |
6732 | 8201 If @var{h} is a vector, return a cell array including the property\n\ |
8202 values or lists respectively.\n\ | |
6406 | 8203 @end deftypefn") |
8204 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8205 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8206 |
6406 | 8207 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
|
8208 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8209 Cell vals; |
6406 | 8210 |
8211 int nargin = args.length (); | |
8212 | |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8213 bool use_cell_format = false; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8214 |
6406 | 8215 if (nargin == 1 || nargin == 2) |
8216 { | |
12678
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8217 if (args(0).is_empty()) |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8218 { |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8219 retval = Matrix (); |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8220 return retval; |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8221 } |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8222 |
6732 | 8223 ColumnVector hcv (args(0).vector_value ()); |
6406 | 8224 |
8225 if (! error_state) | |
6732 | 8226 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8227 octave_idx_type len = hcv.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8228 |
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
|
8229 if (nargin == 1 && len > 1) |
6732 | 8230 { |
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
|
8231 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
|
8232 |
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
|
8233 if (! error_state) |
6732 | 8234 { |
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
|
8235 for (octave_idx_type n = 1; n < len; n++) |
6732 | 8236 { |
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
|
8237 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
|
8238 |
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
|
8239 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
|
8240 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
|
8241 |
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
|
8242 if (t != t0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8243 { |
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
|
8244 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
|
8245 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8246 } |
6732 | 8247 } |
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
|
8248 |
6732 | 8249 } |
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
|
8250 } |
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
|
8251 |
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
|
8252 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
|
8253 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8254 if (nargin > 1 && args(1).is_cellstr ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8255 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8256 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
|
8257 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8258 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
|
8259 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8260 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
|
8261 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8262 use_cell_format = true; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8263 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8264 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
|
8265 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8266 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
|
8267 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8268 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
|
8269 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8270 if (obj) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8271 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8272 for (octave_idx_type m = 0; ! error_state && m < plen; m++) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8273 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8274 caseless_str property = plist(m); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8275 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8276 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
|
8277 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8278 } |
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
|
8279 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
|
8280 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8281 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
|
8282 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
|
8283 } |
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
|
8284 } |
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
|
8285 } |
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
|
8286 else |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8287 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
|
8288 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8289 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8290 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8291 caseless_str property; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8292 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8293 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
|
8294 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8295 property = args(1).string_value (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8296 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8297 if (error_state) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8298 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
|
8299 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8300 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8301 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
|
8302 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8303 if (! error_state) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8304 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8305 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
|
8306 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8307 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
|
8308 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8309 if (obj) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8310 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8311 if (nargin == 1) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8312 vals(n) = obj.get (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8313 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8314 vals(n) = obj.get (property); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8315 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8316 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8317 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8318 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
|
8319 break; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8320 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8321 } |
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
|
8322 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8323 } |
6732 | 8324 } |
8325 } | |
6406 | 8326 else |
6732 | 8327 error ("get: expecting graphics handle as first argument"); |
6406 | 8328 } |
8329 else | |
8330 print_usage (); | |
8331 | |
6733 | 8332 if (! error_state) |
6732 | 8333 { |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8334 if (use_cell_format) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8335 retval = vals; |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8336 else |
13955
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8337 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8338 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
|
8339 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8340 if (len == 0) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8341 retval = Matrix (); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8342 else if (len == 1) |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8343 retval = vals(0); |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8344 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
|
8345 { |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8346 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
|
8347 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8348 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
|
8349 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
|
8350 |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8351 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
|
8352 } |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8353 else |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8354 retval = vals; |
ffbbe6719ef5
Implement support for cellstr argument in get() function.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13940
diff
changeset
|
8355 } |
6732 | 8356 } |
8357 | |
6406 | 8358 return retval; |
8359 } | |
8360 | |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8361 /* |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8362 %!assert (get (findobj (0, 'Tag', 'nonexistenttag'), 'nonexistentproperty'), []) |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8363 */ |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8364 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
8365 // 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
|
8366 // 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
|
8367 // 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
|
8368 |
7379 | 8369 DEFUN (__get__, args, , |
8370 "-*- texinfo -*-\n\ | |
8371 @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
|
8372 Undocumented internal function.\n\ |
7379 | 8373 @end deftypefn") |
8374 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8375 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8376 |
7379 | 8377 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
|
8378 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8379 Cell vals; |
7379 | 8380 |
8381 int nargin = args.length (); | |
8382 | |
8383 if (nargin == 1) | |
8384 { | |
8385 ColumnVector hcv (args(0).vector_value ()); | |
8386 | |
8387 if (! error_state) | |
8388 { | |
8389 octave_idx_type len = hcv.length (); | |
8390 | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8391 vals.resize (dim_vector (len, 1)); |
7379 | 8392 |
8393 for (octave_idx_type n = 0; n < len; n++) | |
8394 { | |
8395 graphics_object obj = gh_manager::get_object (hcv(n)); | |
8396 | |
8397 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
|
8398 vals(n) = obj.get (true); |
7379 | 8399 else |
8400 { | |
8401 error ("get: invalid handle (= %g)", hcv(n)); | |
8402 break; | |
8403 } | |
8404 } | |
8405 } | |
8406 else | |
8407 error ("get: expecting graphics handle as first argument"); | |
8408 } | |
8409 else | |
8410 print_usage (); | |
8411 | |
8412 if (! error_state) | |
8413 { | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8414 octave_idx_type len = vals.numel (); |
7379 | 8415 |
8416 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
|
8417 retval = vals; |
7379 | 8418 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
|
8419 retval = vals(0); |
7379 | 8420 } |
8421 | |
8422 return retval; | |
8423 } | |
8424 | |
6406 | 8425 static octave_value |
8426 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
|
8427 bool integer_figure_handle, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8428 const octave_value_list& args) |
6406 | 8429 { |
8430 octave_value retval; | |
8431 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8432 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8433 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8434 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8435 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8436 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8437 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8438 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8439 if (xargs(i).is_string () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8440 && p.compare (xargs(i).string_value ())) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8441 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8442 if (i < (xargs.length () - 1)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8443 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8444 val = xargs(i+1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8445 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8446 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8447 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8448 xargs = xargs.splice (i, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8449 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8450 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8451 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8452 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8453 error ("__go_%s__: missing value for parent property", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8454 go_name.c_str ()); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8455 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8456 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8457 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8458 val = args(0).double_value (); |
6406 | 8459 |
8460 if (! error_state) | |
8461 { | |
8462 graphics_handle parent = gh_manager::lookup (val); | |
8463 | |
7056 | 8464 if (parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8465 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8466 graphics_handle h |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8467 = 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
|
8468 integer_figure_handle, |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8469 false, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8470 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8471 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8472 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8473 adopt (parent, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8474 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8475 xset (h, xargs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8476 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
|
8477 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8478 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8479 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8480 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8481 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8482 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8483 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8484 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8485 error ("__go%s__: unable to create graphics handle", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8486 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8487 } |
6406 | 8488 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8489 error ("__go_%s__: invalid parent", go_name.c_str ()); |
6406 | 8490 } |
8491 else | |
8492 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
8493 | |
8494 return retval; | |
8495 } | |
8496 | |
8497 DEFUN (__go_figure__, args, , | |
8498 "-*- texinfo -*-\n\ | |
8499 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ | |
6945 | 8500 Undocumented internal function.\n\ |
6406 | 8501 @end deftypefn") |
8502 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8503 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8504 |
6406 | 8505 octave_value retval; |
8506 | |
8507 if (args.length () > 0) | |
8508 { | |
8509 double val = args(0).double_value (); | |
8510 | |
8511 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8512 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8513 if (is_figure (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8514 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8515 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8516 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8517 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8518 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8519 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8520 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8521 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8522 { |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8523 bool int_fig_handle = true; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8524 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8525 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
|
8526 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8527 graphics_handle h = octave_NaN; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8528 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8529 if (xisnan (val)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8530 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8531 caseless_str p ("integerhandle"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8532 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8533 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
|
8534 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8535 if (xargs(i).is_string () |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8536 && p.compare (xargs(i).string_value ())) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8537 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8538 if (i < (xargs.length () - 1)) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8539 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8540 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
|
8541 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8542 if (! error_state) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8543 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8544 caseless_str on ("on"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8545 int_fig_handle = on.compare (pval); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8546 xargs = xargs.splice (i, 2); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8547 break; |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8548 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8549 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8550 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8551 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8552 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8553 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
|
8554 int_fig_handle, |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8555 false, false); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8556 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8557 if (! int_fig_handle) |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8558 { |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8559 // We need to intiailize the integerhandle |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8560 // property without calling the set_integerhandle |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8561 // 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
|
8562 // handle value... |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8563 |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8564 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
|
8565 go.get_properties ().init_integerhandle ("off"); |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8566 } |
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8567 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8568 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
|
8569 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
|
8570 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8571 if (! error_state && h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8572 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8573 adopt (0, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8574 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8575 gh_manager::push_figure (h); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8576 |
13816
7ee18dc46bbb
new and improved non-integer figure handles
John W. Eaton <jwe@octave.org>
parents:
13804
diff
changeset
|
8577 xset (h, xargs); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8578 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
|
8579 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8580 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8581 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8582 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8583 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8584 error ("__go_figure__: failed to create figure handle"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8585 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8586 } |
6406 | 8587 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8588 error ("__go_figure__: expecting figure number to be double value"); |
6406 | 8589 } |
8590 else | |
8591 print_usage (); | |
8592 | |
8593 return retval; | |
8594 } | |
8595 | |
8596 #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
|
8597 gh_manager::auto_lock guard; \ |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8598 \ |
6406 | 8599 octave_value retval; \ |
8600 \ | |
8601 if (args.length () > 0) \ | |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8602 retval = make_graphics_object (#TYPE, false, args); \ |
6406 | 8603 else \ |
8604 print_usage (); \ | |
8605 \ | |
8606 return retval | |
8607 | |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8608 int |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8609 calc_dimensions (const graphics_object& go) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8610 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8611 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8612 int nd = 2; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8613 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8614 if (go.isa ("surface")) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8615 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8616 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8617 if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8618 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8619 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8620 Matrix kids = go.get_properties().get_children (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8621 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8622 for (octave_idx_type i = 0; i < kids.length (); i++) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8623 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8624 graphics_handle hnd = gh_manager::lookup (kids(i)); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8625 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8626 if (hnd.ok ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8627 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8628 const graphics_object& kid = gh_manager::get_object(hnd); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8629 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8630 if (kid.valid_object()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8631 nd = calc_dimensions (kid); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8632 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8633 if (nd == 3) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8634 break; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8635 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8636 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8637 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8638 return nd; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8639 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8640 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8641 DEFUN (__calc_dimensions__, args, , |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8642 "-*- texinfo -*-\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8643 @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
|
8644 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
|
8645 object, whether 2 or 3.\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8646 @end deftypefn") |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8647 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8648 gh_manager::auto_lock guard; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8649 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8650 octave_value retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8651 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8652 int nargin = args.length (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8653 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8654 if (nargin == 1) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8655 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8656 double h = args(0).double_value (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8657 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8658 if (! error_state) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8659 retval = calc_dimensions (gh_manager::get_object (h)); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8660 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8661 error ("__calc_dimensions__: expecting graphics handle as only argument"); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8662 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8663 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8664 print_usage (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8665 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8666 return retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8667 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8668 |
6406 | 8669 DEFUN (__go_axes__, args, , |
8670 "-*- texinfo -*-\n\ | |
8671 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ | |
6945 | 8672 Undocumented internal function.\n\ |
6406 | 8673 @end deftypefn") |
8674 { | |
8675 GO_BODY (axes); | |
8676 } | |
8677 | |
8678 DEFUN (__go_line__, args, , | |
8679 "-*- texinfo -*-\n\ | |
8680 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ | |
6945 | 8681 Undocumented internal function.\n\ |
6406 | 8682 @end deftypefn") |
8683 { | |
8684 GO_BODY (line); | |
8685 } | |
8686 | |
8687 DEFUN (__go_text__, args, , | |
8688 "-*- texinfo -*-\n\ | |
8689 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ | |
6945 | 8690 Undocumented internal function.\n\ |
6406 | 8691 @end deftypefn") |
8692 { | |
8693 GO_BODY (text); | |
8694 } | |
8695 | |
8696 DEFUN (__go_image__, args, , | |
8697 "-*- texinfo -*-\n\ | |
8698 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ | |
6945 | 8699 Undocumented internal function.\n\ |
6406 | 8700 @end deftypefn") |
8701 { | |
8702 GO_BODY (image); | |
8703 } | |
8704 | |
8705 DEFUN (__go_surface__, args, , | |
8706 "-*- texinfo -*-\n\ | |
8707 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ | |
6945 | 8708 Undocumented internal function.\n\ |
6406 | 8709 @end deftypefn") |
8710 { | |
8711 GO_BODY (surface); | |
8712 } | |
8713 | |
6807 | 8714 DEFUN (__go_patch__, args, , |
8715 "-*- texinfo -*-\n\ | |
8716 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ | |
6945 | 8717 Undocumented internal function.\n\ |
6807 | 8718 @end deftypefn") |
8719 { | |
8720 GO_BODY (patch); | |
8721 } | |
8722 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8723 DEFUN (__go_hggroup__, args, , |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8724 "-*- texinfo -*-\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8725 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8726 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8727 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8728 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8729 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8730 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8731 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8732 DEFUN (__go_uimenu__, args, , |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8733 "-*- texinfo -*-\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8734 @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
|
8735 Undocumented internal function.\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8736 @end deftypefn") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8737 { |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8738 GO_BODY (uimenu); |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8739 } |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8740 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8741 DEFUN (__go_uicontrol__, args, , |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8742 "-*- texinfo -*-\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8743 @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
|
8744 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
|
8745 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8746 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8747 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
|
8748 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8749 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8750 DEFUN (__go_uipanel__, args, , |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8751 "-*- texinfo -*-\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8752 @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
|
8753 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
|
8754 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8755 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8756 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
|
8757 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8758 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8759 DEFUN (__go_uicontextmenu__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8760 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8761 @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
|
8762 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8763 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8764 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8765 GO_BODY (uicontextmenu); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8766 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8767 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8768 DEFUN (__go_uitoolbar__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8769 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8770 @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
|
8771 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8772 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8773 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8774 GO_BODY (uitoolbar); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8775 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8776 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8777 DEFUN (__go_uipushtool__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8778 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8779 @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
|
8780 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8781 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8782 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8783 GO_BODY (uipushtool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8784 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8785 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8786 DEFUN (__go_uitoggletool__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8787 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8788 @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
|
8789 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8790 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8791 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8792 GO_BODY (uitoggletool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8793 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8794 |
6406 | 8795 DEFUN (__go_delete__, args, , |
8796 "-*- texinfo -*-\n\ | |
8797 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ | |
6945 | 8798 Undocumented internal function.\n\ |
6406 | 8799 @end deftypefn") |
8800 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8801 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8802 |
6406 | 8803 octave_value_list retval; |
8804 | |
8805 if (args.length () == 1) | |
8806 { | |
8807 graphics_handle h = octave_NaN; | |
8808 | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
8809 const NDArray vals = args (0).array_value (); |
6406 | 8810 |
8811 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8812 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8813 // 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
|
8814 // 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
|
8815 // later want to delete |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8816 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
|
8817 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8818 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8819 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8820 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8821 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8822 error ("delete: invalid graphics object (= %g)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8823 vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8824 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8825 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8826 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8827 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8828 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
|
8829 delete_graphics_objects (vals); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8830 } |
6406 | 8831 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8832 error ("delete: invalid graphics object"); |
6406 | 8833 } |
8834 else | |
8835 print_usage (); | |
8836 | |
8837 return retval; | |
8838 } | |
8839 | |
8840 DEFUN (__go_axes_init__, args, , | |
8841 "-*- texinfo -*-\n\ | |
8842 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ | |
6945 | 8843 Undocumented internal function.\n\ |
6406 | 8844 @end deftypefn") |
8845 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8846 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8847 |
6406 | 8848 octave_value retval; |
8849 | |
8850 int nargin = args.length (); | |
8851 | |
8852 std::string mode = ""; | |
8853 | |
8854 if (nargin == 2) | |
8855 { | |
8856 mode = args(1).string_value (); | |
8857 | |
8858 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8859 return retval; |
6406 | 8860 } |
8861 | |
8862 if (nargin == 1 || nargin == 2) | |
8863 { | |
8864 graphics_handle h = octave_NaN; | |
8865 | |
8866 double val = args(0).double_value (); | |
8867 | |
8868 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8869 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8870 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8871 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8872 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8873 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8874 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8875 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8876 obj.set_defaults (mode); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8877 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8878 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8879 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8880 error ("__go_axes_init__: axis deleted during initialization (= %g)", val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8881 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8882 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8883 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
|
8884 } |
6406 | 8885 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8886 error ("__go_axes_init__: invalid graphics object"); |
6406 | 8887 } |
8888 else | |
8889 print_usage (); | |
8890 | |
8891 return retval; | |
8892 } | |
8893 | |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8894 DEFUN (__go_handles__, args, , |
6406 | 8895 "-*- texinfo -*-\n\ |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8896 @deftypefn {Built-in Function} {} __go_handles__ (@var{show_hidden})\n\ |
6945 | 8897 Undocumented internal function.\n\ |
6406 | 8898 @end deftypefn") |
8899 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8900 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8901 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8902 bool show_hidden = false; |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8903 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8904 if (args.length () > 0) |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8905 show_hidden = args(0).bool_value (); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8906 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8907 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
|
8908 } |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8909 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8910 DEFUN (__go_figure_handles__, args, , |
6425 | 8911 "-*- texinfo -*-\n\ |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8912 @deftypefn {Built-in Function} {} __go_figure_handles__ (@var{show_hidden})\n\ |
6945 | 8913 Undocumented internal function.\n\ |
6425 | 8914 @end deftypefn") |
8915 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8916 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8917 |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8918 bool show_hidden = false; |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8919 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8920 if (args.length () > 0) |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8921 show_hidden = args(0).bool_value (); |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8922 |
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
8923 return octave_value (gh_manager::figure_handle_list (show_hidden)); |
6406 | 8924 } |
8925 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8926 DEFUN (__go_execute_callback__, args, , |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8927 "-*- texinfo -*-\n\ |
10840 | 8928 @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
|
8929 @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
|
8930 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8931 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8932 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8933 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8934 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8935 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8936 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8937 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8938 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8939 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8940 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8941 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8942 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8943 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8944 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8945 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8946 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8947 std::string name = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8948 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8949 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8950 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8951 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8952 gh_manager::execute_callback (h, name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8953 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8954 gh_manager::execute_callback (h, name, args(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8955 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8956 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8957 error ("__go_execute_callback__: invalid callback name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8958 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8959 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8960 error ("__go_execute_callback__: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8961 val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8962 } |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8963 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8964 error ("__go_execute_callback__: invalid graphics object"); |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8965 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8966 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8967 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8968 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8969 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8970 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8971 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8972 DEFUN (__image_pixel_size__, args, , |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8973 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
8974 @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
|
8975 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
|
8976 @end deftypefn") |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8977 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8978 octave_value retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8979 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8980 int nargin = args.length (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8981 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8982 if (nargin == 1) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8983 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8984 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
|
8985 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8986 if (! error_state) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8987 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8988 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
|
8989 if (fobj && fobj.isa ("image")) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8990 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8991 image::properties& ip = |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8992 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
|
8993 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8994 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
|
8995 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
|
8996 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
|
8997 retval = dp; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8998 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8999 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9000 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
|
9001 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9002 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9003 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
|
9004 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9005 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9006 print_usage (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9007 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9008 return retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9009 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
9010 |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9011 gtk_manager *gtk_manager::instance = 0; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9012 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9013 void |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9014 gtk_manager::create_instance (void) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9015 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9016 instance = new gtk_manager (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9017 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9018 if (instance) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9019 singleton_cleanup_list::add (cleanup_instance); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9020 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9021 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9022 graphics_toolkit |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9023 gtk_manager::do_get_toolkit (void) const |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9024 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9025 graphics_toolkit retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9026 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9027 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
|
9028 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9029 if (pl == loaded_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9030 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9031 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
|
9032 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9033 if (pa != available_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9034 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9035 octave_value_list args; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9036 args(0) = dtk; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9037 feval ("graphics_toolkit", args); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9038 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9039 if (! error_state) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9040 pl = loaded_toolkits.find (dtk); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9041 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9042 if (error_state || pl == loaded_toolkits.end ()) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9043 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
|
9044 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9045 retval = pl->second; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9046 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9047 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9048 error ("default graphics toolkit `%s' is not available!", |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9049 dtk.c_str ()); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9050 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9051 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9052 retval = pl->second; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9053 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9054 return retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9055 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9056 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
9057 DEFUN (available_graphics_toolkits, , , |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
9058 "-*- texinfo -*-\n\ |
12215
4ae2a74ed04c
Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12189
diff
changeset
|
9059 @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
|
9060 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
|
9061 @seealso{graphics_toolkit, register_graphics_toolkit}\n\ |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
9062 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
9063 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9064 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9065 |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9066 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
|
9067 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9068 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9069 DEFUN (register_graphics_toolkit, args, , |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9070 "-*- texinfo -*-\n\ |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9071 @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
|
9072 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
|
9073 @seealso{available_graphics_toolkits}\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9074 @end deftypefn") |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9075 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9076 octave_value retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9077 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9078 gh_manager::auto_lock guard; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9079 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9080 if (args.length () == 1) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9081 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9082 std::string name = args(0).string_value (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9083 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9084 if (! error_state) |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9085 gtk_manager::register_toolkit (name); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9086 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9087 error ("register_graphics_toolkit: expecting character string"); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9088 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9089 else |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9090 print_usage (); |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9091 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9092 return retval; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9093 } |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9094 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9095 DEFUN (loaded_graphics_toolkits, , , |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9096 "-*- texinfo -*-\n\ |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9097 @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
|
9098 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
|
9099 @seealso{available_graphics_toolkits}\n\ |
14021
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9100 @end deftypefn") |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9101 { |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9102 gh_manager::auto_lock guard; |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9103 |
e3bed294b117
refactor graphics_toolkit class (bug #31583)
John W. Eaton <jwe@octave.org>
parents:
14016
diff
changeset
|
9104 return octave_value (gtk_manager::loaded_toolkits_list ()); |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
9105 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
9106 |
7408 | 9107 DEFUN (drawnow, args, , |
9108 "-*- texinfo -*-\n\ | |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9109 @deftypefn {Built-in Function} {} drawnow ()\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9110 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9111 @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
|
9112 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
|
9113 any callbacks generated are executed. With the optional argument\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9114 @code{\"expose\"}, only graphic objects are updated and no other events or\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9115 callbacks are processed.\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
9116 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
|
9117 undocumented.\n\ |
7408 | 9118 @end deftypefn") |
9119 { | |
9120 static int drawnow_executing = 0; | |
9121 | |
9122 octave_value retval; | |
9123 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9124 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9125 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
9126 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
9127 frame.protect_var (Vdrawnow_requested, false); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
9128 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
9129 frame.protect_var (drawnow_executing); |
7409 | 9130 |
9131 if (++drawnow_executing <= 1) | |
7408 | 9132 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9133 if (args.length () == 0 || args.length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9134 { |
13801
195ff3561152
allow figure handles to be non-integers
John W. Eaton <jwe@octave.org>
parents:
13799
diff
changeset
|
9135 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
|
9136 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9137 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
|
9138 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9139 graphics_handle h = gh_manager::lookup (hlist(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9140 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9141 if (h.ok () && h != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9142 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9143 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9144 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9145 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9146 if (fprops.is_modified ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9147 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9148 if (fprops.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9149 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9150 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9151 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
9152 fprops.get_toolkit ().redraw_figure (go); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9153 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9154 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9155 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9156 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9157 fprops.set_modified (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9158 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9159 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9160 } |
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 bool do_events = true; |
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 if (args.length () == 1) |
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 caseless_str val (args(0).string_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9167 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9168 if (! error_state && val.compare ("expose")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9169 do_events = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9170 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9171 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9172 error ("drawnow: invalid argument, expected `expose' as argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9173 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9174 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9175 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9176 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9177 if (do_events) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9178 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9179 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9180 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9181 gh_manager::process_events (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9182 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9183 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9184 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9185 } |
7409 | 9186 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
|
9187 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9188 std::string term, file, debug_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9189 bool mono; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9190 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9191 term = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9192 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9193 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9194 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9195 file = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9196 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9197 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9198 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9199 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
|
9200 if (pos > 0) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9201 file = file.substr (pos); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9202 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9203 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9204 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
|
9205 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9206 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9207 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9208 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
|
9209 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9210 file_stat fs (dirname); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9211 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9212 if (! (fs && fs.is_dir ())) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9213 { |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9214 error ("drawnow: nonexistent directory `%s'", |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9215 dirname.c_str ()); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9216 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9217 return retval; |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
9218 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9219 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9220 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9221 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9222 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
|
9223 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9224 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9225 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9226 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
|
9227 : ""); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9228 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9229 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9230 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9231 graphics_handle h = gcf (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9232 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9233 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9234 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9235 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9236 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9237 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9238 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
9239 go.get_toolkit () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9240 .print_figure (go, term, file, mono, debug_file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9241 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9242 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9243 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9244 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9245 error ("drawnow: nothing to draw"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9246 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9247 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9248 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
|
9249 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9250 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9251 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
|
9252 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9253 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9254 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
|
9255 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9256 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9257 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
|
9258 } |
7408 | 9259 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9260 print_usage (); |
7408 | 9261 } |
7409 | 9262 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9263 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9264 |
7408 | 9265 return retval; |
9266 } | |
9267 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
9268 DEFUN (addlistener, args, , |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9269 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
9270 @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
|
9271 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
|
9272 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
|
9273 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
|
9274 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9275 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9276 @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
|
9277 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9278 @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
|
9279 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
|
9280 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
|
9281 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
|
9282 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
|
9283 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
|
9284 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
|
9285 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
|
9286 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9287 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9288 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9289 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9290 @group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9291 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
|
9292 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
|
9293 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9294 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
9295 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
|
9296 @end group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9297 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9298 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9299 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9300 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9301 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9302 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9303 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9304 |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9305 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
|
9306 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9307 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9308 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9309 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9310 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9311 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9312 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9313 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9314 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9315 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9316 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9317 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9318 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9319 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9320 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9321 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
|
9322 |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9323 if (args.length () == 4) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9324 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9325 caseless_str persistent = args(3).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9326 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9327 go.add_property_listener (pname, args(2), PERSISTENT); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9328 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9329 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9330 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9331 error ("addlistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9332 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9333 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9334 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9335 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
|
9336 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9337 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9338 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9339 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9340 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9341 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9342 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9343 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9344 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9345 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9346 DEFUN (dellistener, args, , |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9347 "-*- texinfo -*-\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9348 @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
|
9349 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
|
9350 @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
|
9351 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
|
9352 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
|
9353 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9354 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
|
9355 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
|
9356 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9357 Example:\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9358 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9359 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9360 @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
|
9361 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
|
9362 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
|
9363 endfunction\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9364 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9365 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
|
9366 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
|
9367 dellistener (gcf, \"position\", c);\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9368 @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
|
9369 @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
|
9370 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9371 @end deftypefn") |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9372 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9373 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
|
9374 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9375 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
|
9376 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9377 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
|
9378 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9379 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
|
9380 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9381 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9382 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9383 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9384 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9385 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9386 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9387 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9388 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9389 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9390 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9391 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9392 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9393 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9394 go.delete_property_listener (pname, octave_value (), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9395 else |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9396 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9397 caseless_str persistent = args(2).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9398 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9399 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9400 go.delete_property_listener (pname, octave_value (), PERSISTENT); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9401 go.delete_property_listener (pname, octave_value (), POSTSET); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9402 } |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9403 else |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9404 go.delete_property_listener (pname, args(2), POSTSET); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9405 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9406 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9407 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9408 error ("dellistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9409 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9410 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9411 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9412 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
|
9413 } |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9414 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9415 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
|
9416 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9417 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9418 print_usage (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9419 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9420 return retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9421 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9422 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9423 DEFUN (addproperty, args, , |
7869 | 9424 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
9425 @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
|
9426 @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
|
9427 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
|
9428 @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
|
9429 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
|
9430 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
|
9431 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9432 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9433 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9434 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9435 @item string\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9436 A string property. @var{arg} contains the default string value.\n\ |
10840 | 9437 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9438 @item any\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9439 An un-typed property. This kind of property can hold any octave\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9440 value. @var{args} contains the default value.\n\ |
10840 | 9441 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9442 @item radio\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9443 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
|
9444 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
|
9445 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
|
9446 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
|
9447 an optional second string argument.\n\ |
10840 | 9448 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9449 @item boolean\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9450 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
|
9451 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
|
9452 the default property value.\n\ |
10840 | 9453 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9454 @item double\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9455 A scalar double property. @var{arg} contains the default value.\n\ |
10840 | 9456 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9457 @item handle\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9458 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
|
9459 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
|
9460 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
|
9461 the empty matrix.\n\ |
10840 | 9462 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9463 @item data\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9464 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
|
9465 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
|
9466 the empty matrix.\n\ |
10840 | 9467 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9468 @item color\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9469 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
|
9470 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
|
9471 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
|
9472 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
|
9473 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9474 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9475 @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
|
9476 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
|
9477 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
|
9478 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
|
9479 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9480 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9481 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9482 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9483 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9484 @group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9485 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9486 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
|
9487 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9488 @end group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9489 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9490 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9491 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9492 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9493 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9494 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9495 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9496 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9497 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9498 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9499 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9500 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9501 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9502 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9503 double h = args(1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9504 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9505 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9506 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9507 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9508 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9509 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9510 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9511 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9512 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9513 std::string type = args(2).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9514 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9515 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9516 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9517 if (! go.get_properties ().has_property (name)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9518 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9519 property p = property::create (name, gh, type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9520 args.splice (0, 3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9521 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9522 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9523 go.get_properties ().insert_property (name, p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9524 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9525 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9526 error ("addproperty: a `%s' property already exists in the graphics object", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9527 name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9528 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9529 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9530 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
|
9531 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9532 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9533 error ("addproperty: invalid graphics object (= %g)", h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9534 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9535 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9536 error ("addproperty: invalid handle value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9537 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9538 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9539 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
|
9540 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9541 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9542 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9543 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9544 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9545 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9546 |
6595 | 9547 octave_value |
7447 | 9548 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
|
9549 const std::string& func) |
6595 | 9550 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9551 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9552 |
6595 | 9553 graphics_object obj = gh_manager::get_object (handle); |
9554 octave_value retval; | |
9555 | |
9556 if (obj) | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9557 retval = obj.get (caseless_str (property)); |
6595 | 9558 else |
9559 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
9560 | |
9561 return retval; | |
9562 } | |
9563 | |
9564 bool | |
7447 | 9565 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
|
9566 const octave_value& arg, const std::string& func) |
6595 | 9567 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9568 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9569 |
6595 | 9570 graphics_object obj = gh_manager::get_object (handle); |
9571 int ret = false; | |
9572 | |
9573 if (obj) | |
9574 { | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9575 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
|
9576 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9577 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9578 ret = true; |
6595 | 9579 } |
9580 else | |
9581 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
9582 | |
9583 return ret; | |
9584 } | |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9585 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9586 static bool |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9587 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
|
9588 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9589 octave_value_list args (2); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9590 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9591 args(0) = o1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9592 args(1) = o2; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9593 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9594 octave_value_list result = feval ("isequal", args, 1); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9595 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9596 if (! error_state && result.length () > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9597 return result(0).bool_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9598 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9599 return false; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9600 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9601 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9602 static std::map<uint32_t, bool> waitfor_results; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9603 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9604 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9605 cleanup_waitfor_id (uint32_t id) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9606 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9607 waitfor_results.erase (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9608 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9609 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9610 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9611 do_cleanup_waitfor_listener (const octave_value& listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9612 listener_mode mode = POSTSET) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9613 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9614 Cell c = listener.cell_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9615 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9616 if (c.numel () >= 4) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9617 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9618 double h = c(2).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9619 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9620 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9621 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9622 caseless_str pname = c(3).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9623 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9624 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9625 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9626 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9627 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9628 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9629 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9630 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9631 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9632 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9633 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9634 if (go.get_properties ().has_property (pname)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9635 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9636 go.get_properties () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9637 .delete_listener (pname, listener, mode); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9638 if (mode == POSTSET) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9639 go.get_properties () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9640 .delete_listener (pname, listener, PERSISTENT); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9641 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9642 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9643 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9644 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9645 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9646 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9647 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9648 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9649 cleanup_waitfor_postset_listener(const octave_value& listener) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9650 { do_cleanup_waitfor_listener (listener, POSTSET); } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9651 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9652 static void |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9653 cleanup_waitfor_predelete_listener(const octave_value& listener) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9654 { do_cleanup_waitfor_listener (listener, PREDELETE); } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9655 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9656 static octave_value_list |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9657 waitfor_listener (const octave_value_list& args, int) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9658 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9659 if (args.length () > 3) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9660 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9661 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
|
9662 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9663 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9664 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9665 if (args.length () > 5) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9666 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9667 double h = args(0).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9668 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9669 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9670 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9671 caseless_str pname = args(4).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9672 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9673 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9674 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9675 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9676 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9677 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9678 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9679 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9680 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9681 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9682 octave_value pvalue = go.get (pname); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9683 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9684 if (compare_property_values (pvalue, args(5))) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9685 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9686 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9687 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9688 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9689 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9690 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9691 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9692 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9693 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9694 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9695 return octave_value_list (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9696 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9697 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9698 static octave_value_list |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9699 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
|
9700 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9701 if (args.length () > 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9702 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9703 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
|
9704 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9705 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9706 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9707 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9708 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9709 return octave_value_list (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9710 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9711 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9712 DEFUN (waitfor, args, , |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9713 "-*- texinfo -*-\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9714 @deftypefn {Built-in Function} {} waitfor (@var{h})\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9715 @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
|
9716 @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
|
9717 @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
|
9718 Suspend the execution of the current program until a condition is\n\ |
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13925
diff
changeset
|
9719 satisfied on the graphics handle @var{h}. While the program is suspended\n\ |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9720 graphics events are still being processed normally, allowing callbacks to\n\ |
13929
9cae456085c2
Grammarcheck of documentation before 3.6.0 release.
Rik <octave@nomad.inbox5.com>
parents:
13925
diff
changeset
|
9721 modify the state of graphics objects. This function is reentrant and can be\n\ |
13924
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9722 called from a callback, while another @code{waitfor} call is pending at\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9723 top-level.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9724 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9725 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
|
9726 @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
|
9727 returns immediately.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9728 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9729 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
|
9730 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
|
9731 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
|
9732 immediately.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9733 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9734 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
|
9735 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
|
9736 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
|
9737 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
|
9738 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
|
9739 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9740 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
|
9741 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
|
9742 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
|
9743 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
|
9744 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
|
9745 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9746 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
|
9747 @code{\\timeout} instead.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9748 \n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9749 In all cases, typing CTRL-C stops program execution immediately.\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9750 @seealso{isequal}\n\ |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9751 @end deftypefn") |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9752 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9753 if (args.length () > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9754 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9755 double h = args(0).double_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9756 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9757 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9758 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9759 caseless_str pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9760 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9761 unwind_protect frame; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9762 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9763 static uint32_t id_counter = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9764 uint32_t id = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9765 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9766 int max_arg_index = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9767 int timeout_index = -1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9768 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9769 int timeout = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9770 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9771 if (args.length () > 1) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9772 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9773 pname = args(1).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9774 if (! error_state |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9775 && ! pname.empty () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9776 && ! pname.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9777 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9778 if (pname.compare ("\\timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9779 pname = "timeout"; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9780 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9781 static octave_value wf_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9782 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9783 if (! wf_listener.is_defined ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9784 wf_listener = |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9785 octave_value (new octave_builtin (waitfor_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9786 "waitfor_listener")); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9787 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9788 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9789 if (args.length () > 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9790 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9791 if (args(2).is_string ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9792 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9793 caseless_str s = args(2).string_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9794 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9795 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9796 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9797 if (s.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9798 timeout_index = 2; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9799 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9800 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9801 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9802 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9803 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9804 max_arg_index++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9805 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9806 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9807 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
|
9808 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9809 id = id_counter++; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9810 frame.add_fcn (cleanup_waitfor_id, id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9811 waitfor_results[id] = false; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9812 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9813 listener(0) = wf_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9814 listener(1) = octave_uint32 (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9815 listener(2) = h; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9816 listener(3) = pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9817 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9818 if (max_arg_index >= 2) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9819 listener(4) = args(2); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9820 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9821 octave_value ov_listener (listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9822 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9823 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9824 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9825 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9826 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9827 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9828 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9829 graphics_object go = gh_manager::get_object (handle); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9830 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9831 if (max_arg_index >= 2 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9832 && compare_property_values (go.get (pname), |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9833 args(2))) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9834 waitfor_results[id] = true; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9835 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9836 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9837 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9838 frame.add_fcn (cleanup_waitfor_postset_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9839 ov_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9840 go.add_property_listener (pname, ov_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9841 POSTSET); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9842 go.add_property_listener (pname, ov_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9843 PERSISTENT); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9844 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9845 if (go.get_properties () |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9846 .has_dynamic_property (pname)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9847 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9848 static octave_value wf_del_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9849 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9850 if (! wf_del_listener.is_defined ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9851 wf_del_listener = |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9852 octave_value (new octave_builtin |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9853 (waitfor_del_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9854 "waitfor_del_listener")); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9855 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9856 Cell del_listener (1, 4); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9857 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9858 del_listener(0) = wf_del_listener; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9859 del_listener(1) = octave_uint32 (id); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9860 del_listener(2) = h; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9861 del_listener(3) = pname; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9862 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9863 octave_value ov_del_listener (del_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9864 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9865 frame.add_fcn (cleanup_waitfor_predelete_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9866 ov_del_listener); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9867 go.add_property_listener (pname, ov_del_listener, |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9868 PREDELETE); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9869 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9870 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9871 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9872 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9873 else if (error_state || pname.empty ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9874 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
|
9875 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9876 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9877 if (! error_state |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9878 && timeout_index < 0 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9879 && args.length () > (max_arg_index + 1)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9880 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9881 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
|
9882 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9883 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9884 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9885 if (s.compare ("timeout")) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9886 timeout_index = max_arg_index + 1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9887 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9888 error ("waitfor: invalid parameter `%s'", s.c_str ()); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9889 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9890 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9891 error ("waitfor: invalid parameter, expected `timeout'"); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9892 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9893 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9894 if (! error_state && timeout_index >= 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9895 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9896 if (args.length () > (timeout_index + 1)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9897 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9898 timeout = static_cast<int> |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9899 (args(timeout_index + 1).scalar_value ()); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9900 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9901 if (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9902 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9903 if (timeout < 1) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9904 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9905 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
|
9906 timeout = 1; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9907 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9908 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9909 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9910 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
|
9911 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9912 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9913 error ("waitfor: missing timeout value"); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9914 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9915 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9916 // 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
|
9917 // assumes that an object handle is unique, which is a fair |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9918 // assumptions, except for figures. If a figure is destroyed |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9919 // 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
|
9920 // 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
|
9921 // 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
|
9922 // possibility in practice, though. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9923 // |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9924 // 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
|
9925 // 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
|
9926 // would not stop. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9927 // |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9928 // The only "good" implementation would require object |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9929 // listeners, similar to property listeners. |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9930 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9931 time_t start = 0; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9932 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9933 if (timeout > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9934 start = time (0); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9935 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9936 while (! error_state) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9937 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9938 if (true) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9939 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9940 gh_manager::auto_lock guard; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9941 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9942 graphics_handle handle = gh_manager::lookup (h); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9943 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9944 if (handle.ok ()) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9945 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9946 if (! pname.empty () && waitfor_results[id]) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9947 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9948 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9949 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9950 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9951 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9952 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9953 octave_usleep (100000); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9954 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9955 OCTAVE_QUIT; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9956 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9957 command_editor::run_event_hooks (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9958 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9959 if (timeout > 0) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9960 { |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9961 if (start + timeout < time (0)) |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9962 break; |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9963 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9964 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9965 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9966 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9967 error ("waitfor: invalid handle value."); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9968 } |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9969 else |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9970 print_usage (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9971 |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9972 return octave_value (); |
3b654a0753b1
Implement waitfor, uiwait and uiresume.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13910
diff
changeset
|
9973 } |