Mercurial > octave-dspies
annotate src/graphics.cc @ 12159:1f56327759e5
disable warning about missing freetype library
author | Konstantinos Poulios <logari81@googlemail.com> |
---|---|
date | Tue, 25 Jan 2011 10:47:01 +0100 |
parents | 0b9c1a7e350a |
children | 18e9a8da7d18 |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2007-2011 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> |
6406 | 30 |
31 #include <algorithm> | |
32 #include <list> | |
33 #include <map> | |
34 #include <set> | |
35 #include <string> | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
36 #include <sstream> |
6406 | 37 |
7409 | 38 #include "file-ops.h" |
39 #include "file-stat.h" | |
40 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
41 #include "cmd-edit.h" |
6705 | 42 #include "defun.h" |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
43 #include "display.h" |
6705 | 44 #include "error.h" |
6595 | 45 #include "graphics.h" |
7409 | 46 #include "input.h" |
6705 | 47 #include "ov.h" |
48 #include "oct-obj.h" | |
49 #include "oct-map.h" | |
50 #include "ov-fcn-handle.h" | |
51 #include "parse.h" | |
7409 | 52 #include "toplev.h" |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
53 #include "txt-eng-ft.h" |
7222 | 54 #include "unwind-prot.h" |
6595 | 55 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
56 // 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
|
57 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
|
58 |
6406 | 59 static void |
60 gripe_set_invalid (const std::string& pname) | |
61 { | |
62 error ("set: invalid value for %s property", pname.c_str ()); | |
63 } | |
64 | |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
65 // 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
|
66 // 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
|
67 // 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
|
68 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
69 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
|
70 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
|
71 const std::set<std::string>& pnames, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
72 const caseless_str& pname) |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
73 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
74 size_t len = pname.length (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
75 std::set<std::string> matches; |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
76 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
77 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
|
78 p != pnames.end (); p++) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
79 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
80 if (pname.compare (*p, len)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
81 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
82 if (len == p->length ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
83 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
84 // Exact match. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
85 return pname; |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
88 matches.insert (*p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
89 } |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
90 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
91 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
92 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
|
93 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
94 if (num_matches == 0) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
95 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
96 error ("%s: unknown %s property %s", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
97 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
|
98 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
99 else if (num_matches > 1) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
100 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
101 string_vector sv (matches); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
102 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
103 std::ostringstream os; |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
104 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
105 sv.list_in_columns (os); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
106 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
107 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
|
108 |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
109 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
|
110 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
|
111 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
112 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
|
113 { |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
114 // 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
|
115 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
116 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
|
117 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
118 warning_with_id ("Octave:abbreviated-property-match", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
119 "%s: allowing %s to match %s property %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
120 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
|
121 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
|
122 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
123 return possible_match; |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
124 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
125 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
126 return caseless_str (); |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
127 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
128 |
7363 | 129 static Matrix |
130 jet_colormap (void) | |
131 { | |
132 Matrix cmap (64, 3, 0.0); | |
133 | |
134 for (octave_idx_type i = 0; i < 64; i++) | |
135 { | |
136 // This is the jet colormap. It would be nice to be able | |
137 // to feval the jet function but since there is a static | |
138 // property object that includes a colormap_property | |
139 // object, we need to initialize this before main is even | |
140 // called, so calling an interpreted function is not | |
141 // possible. | |
142 | |
143 double x = i / 63.0; | |
144 | |
145 if (x >= 3.0/8.0 && x < 5.0/8.0) | |
146 cmap(i,0) = 4.0 * x - 3.0/2.0; | |
147 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
148 cmap(i,0) = 1.0; | |
149 else if (x >= 7.0/8.0) | |
150 cmap(i,0) = -4.0 * x + 9.0/2.0; | |
151 | |
152 if (x >= 1.0/8.0 && x < 3.0/8.0) | |
153 cmap(i,1) = 4.0 * x - 1.0/2.0; | |
154 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
155 cmap(i,1) = 1.0; | |
156 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
157 cmap(i,1) = -4.0 * x + 7.0/2.0; | |
158 | |
159 if (x < 1.0/8.0) | |
160 cmap(i,2) = 4.0 * x + 1.0/2.0; | |
161 else if (x >= 1.0/8.0 && x < 3.0/8.0) | |
162 cmap(i,2) = 1.0; | |
163 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
164 cmap(i,2) = -4.0 * x + 5.0/2.0; | |
165 } | |
166 | |
167 return cmap; | |
168 } | |
169 | |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
170 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
171 default_screendepth (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
172 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
173 return display_info::depth (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
174 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
175 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
176 static Matrix |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
177 default_screensize (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
178 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
179 Matrix retval (1, 4, 1.0); |
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 retval(2) = display_info::width (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
182 retval(3) = display_info::height (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
183 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
184 return retval; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
185 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
186 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
187 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
188 default_screenpixelsperinch (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
189 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
190 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
|
191 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
192 |
7363 | 193 static Matrix |
194 default_colororder (void) | |
195 { | |
196 Matrix retval (7, 3, 0.0); | |
197 | |
198 retval(0,2) = 1.0; | |
199 | |
200 retval(1,1) = 0.5; | |
201 | |
202 retval(2,0) = 1.0; | |
203 | |
204 retval(3,1) = 0.75; | |
205 retval(3,2) = 0.75; | |
206 | |
207 retval(4,0) = 0.75; | |
208 retval(4,2) = 0.75; | |
209 | |
210 retval(5,0) = 0.75; | |
211 retval(5,1) = 0.75; | |
212 | |
213 retval(6,0) = 0.25; | |
214 retval(6,1) = 0.25; | |
215 retval(6,2) = 0.25; | |
216 | |
217 return retval; | |
218 } | |
219 | |
220 static Matrix | |
221 default_lim (void) | |
222 { | |
223 Matrix m (1, 2, 0); | |
224 m(1) = 1; | |
225 return m; | |
226 } | |
227 | |
228 static Matrix | |
229 default_data (void) | |
230 { | |
231 Matrix retval (1, 2); | |
232 | |
233 retval(0) = 0; | |
234 retval(1) = 1; | |
235 | |
236 return retval; | |
237 } | |
238 | |
7427 | 239 static Matrix |
240 default_axes_position (void) | |
241 { | |
242 Matrix m (1, 4, 0.0); | |
243 m(0) = 0.13; | |
244 m(1) = 0.11; | |
245 m(2) = 0.775; | |
246 m(3) = 0.815; | |
247 return m; | |
248 } | |
249 | |
250 static Matrix | |
251 default_axes_outerposition (void) | |
252 { | |
253 Matrix m (1, 4, 0.0); | |
254 m(2) = m(3) = 1.0; | |
255 return m; | |
256 } | |
257 | |
7445 | 258 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
259 default_axes_tick (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
260 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
261 Matrix m (1, 6, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
262 m(0) = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
263 m(1) = 0.2; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
264 m(2) = 0.4; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
265 m(3) = 0.6; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
266 m(4) = 0.8; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
267 m(5) = 1.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
268 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
269 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
270 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
271 static Matrix |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
272 default_axes_ticklength (void) |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
273 { |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
274 Matrix m (1, 2, 0.01); |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
275 m(1) = 0.025; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
276 return m; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
277 } |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
278 |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
279 static Matrix |
7445 | 280 default_figure_position (void) |
281 { | |
282 Matrix m (1, 4, 0.0); | |
283 m(0) = 300; | |
284 m(1) = 200; | |
285 m(2) = 560; | |
286 m(3) = 420; | |
287 return m; | |
288 } | |
289 | |
7427 | 290 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
291 default_figure_papersize (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
292 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
293 Matrix m (1, 2, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
294 m(0) = 8.5; |
8961
6b87f2f34fdd
graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents:
8944
diff
changeset
|
295 m(1) = 11.0; |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
296 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
297 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
298 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
299 static Matrix |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
300 default_figure_paperposition (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
301 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
302 Matrix m (1, 4, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
303 m(0) = 0.25; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
304 m(1) = 2.50; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
305 m(2) = 8.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
306 m(3) = 6.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
307 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
308 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
309 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
310 static Matrix |
7427 | 311 convert_position (const Matrix& pos, const caseless_str& from_units, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
312 const caseless_str& to_units, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
313 const Matrix& parent_dim = Matrix (1, 2, 0.0)) |
7427 | 314 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
315 Matrix retval (1, pos.numel ()); |
7427 | 316 double res = 0; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
317 bool is_rectangle = (pos.numel () == 4); |
7427 | 318 |
319 if (from_units.compare ("pixels")) | |
320 retval = pos; | |
321 else if (from_units.compare ("normalized")) | |
322 { | |
323 retval(0) = pos(0) * parent_dim(0) + 1; | |
324 retval(1) = pos(1) * parent_dim(1) + 1; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
325 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
326 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
327 retval(2) = pos(2) * parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
328 retval(3) = pos(3) * parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
329 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
330 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
331 retval(2) = 0; |
7427 | 332 } |
333 else if (from_units.compare ("characters")) | |
334 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
335 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
336 res = xget (0, "screenpixelsperinch").double_value (); |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
337 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
338 double f = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
339 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
340 // FIXME -- this assumes the system font is Helvetica 10pt |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
341 // (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
|
342 f = 12.0 * res / 74.951; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
343 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
344 if (f > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
345 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
346 retval(0) = 0.5 * pos(0) * f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
347 retval(1) = pos(1) * f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
348 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
349 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
350 retval(2) = 0.5 * pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
351 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
352 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
353 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
354 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
355 } |
7427 | 356 } |
357 else | |
358 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
359 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
360 res = xget (0, "screenpixelsperinch").double_value (); |
7427 | 361 |
362 double f = 0.0; | |
363 | |
364 if (from_units.compare ("points")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
365 f = res / 72.0; |
7427 | 366 else if (from_units.compare ("inches")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
367 f = res; |
7427 | 368 else if (from_units.compare ("centimeters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
369 f = res / 2.54; |
7427 | 370 |
371 if (f > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
372 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
373 retval(0) = pos(0) * f + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
374 retval(1) = pos(1) * f + 1; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
375 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
376 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
377 retval(2) = pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
378 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
379 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
380 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
381 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
382 } |
7427 | 383 } |
384 | |
385 if (! to_units.compare ("pixels")) | |
386 { | |
387 if (to_units.compare ("normalized")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
388 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
389 retval(0) = (retval(0) - 1) / parent_dim(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
390 retval(1) = (retval(1) - 1) / parent_dim(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
391 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
392 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
393 retval(2) /= parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
394 retval(3) /= parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
395 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
396 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
397 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
398 } |
7427 | 399 else if (to_units.compare ("characters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
400 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
401 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
402 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
403 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
404 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
405 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
406 f = 12.0 * res / 74.951; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
407 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
408 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
409 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
410 retval(0) = 2 * retval(0) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
411 retval(1) = retval(1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
412 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
413 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
414 retval(2) = 2 * retval(2) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
415 retval(3) = retval(3) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
416 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
417 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
418 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
419 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
420 } |
7427 | 421 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
422 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
423 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
424 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
425 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
426 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
427 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
428 if (to_units.compare ("points")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
429 f = res / 72.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
430 else if (to_units.compare ("inches")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
431 f = res; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
432 else if (to_units.compare ("centimeters")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
433 f = res / 2.54; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
434 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
435 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
436 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
437 retval(0) = (retval(0) - 1) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
438 retval(1) = (retval(1) - 1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
439 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
440 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
441 retval(2) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
442 retval(3) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
443 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
444 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
445 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
446 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
447 } |
7427 | 448 } |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
449 else if (! is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
450 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
451 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
452 return retval; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
453 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
454 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
455 static Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
456 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
|
457 const caseless_str& from_units, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
458 const caseless_str& to_units) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
459 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
460 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
|
461 graphics_object ax = go.get_ancestor ("axes"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
462 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
463 Matrix retval (1, pos.numel (), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
464 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
465 if (ax.valid_object ()) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
466 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
467 const axes::properties& ax_props = |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
468 dynamic_cast<const axes::properties&> (ax.get_properties ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
469 graphics_xform ax_xform = ax_props.get_transform (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
470 bool is_rectangle = (pos.numel () == 4); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
471 Matrix ax_bbox = ax_props.get_boundingbox (true), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
472 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
|
473 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
474 if (from_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
475 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
476 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
477 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
478 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
|
479 v2 = ax_xform.transform (pos(0) + pos(2), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
480 pos(1) + pos(3), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
481 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
482 retval(0) = v1(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
483 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
|
484 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
485 retval(3) = v1(1) - v2(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
486 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
487 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
488 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
489 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
|
490 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
491 retval(0) = v(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
492 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
|
493 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
494 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
495 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
496 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
497 retval = convert_position (pos, from_units, "pixels", ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
498 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
499 if (! to_units.compare ("pixels")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
500 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
501 if (to_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
502 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
503 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
504 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
505 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
|
506 ax_bbox(1) + ax_bbox(3) - retval(1) + 1), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
507 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
|
508 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
|
509 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
510 retval(0) = v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
511 retval(1) = v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
512 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
513 retval(3) = v2(1) - v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
514 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
515 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
516 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
517 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
|
518 ax_bbox(1) + ax_bbox(3) - retval(1) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
519 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
520 retval(0) = v(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
521 retval(1) = v(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
522 retval(2) = v(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
523 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
524 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
525 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
526 retval = convert_position (retval, "pixels", to_units, ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
527 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
528 } |
7427 | 529 |
530 return retval; | |
531 } | |
532 | |
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
|
533 // This function always returns the screensize in 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
|
534 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
|
535 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
|
536 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
537 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
|
538 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
|
539 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
|
540 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
541 |
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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
547 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
|
548 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
|
549 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
|
550 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
|
551 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
552 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
|
553 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
554 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
|
555 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
|
556 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
|
557 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
558 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
|
559 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
560 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
|
561 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
|
562 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
|
563 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
|
564 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
565 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
|
566 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
567 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
|
568 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
|
569 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
|
570 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
571 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
572 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
573 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
|
574 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
|
575 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
|
576 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
|
577 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
|
578 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
579 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
|
580 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
|
581 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
582 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
583 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
584 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
|
585 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
|
586 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
587 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
|
588 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
589 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
|
590 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
591 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
592 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
|
593 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
|
594 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
595 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
|
596 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
|
597 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
598 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
599 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
600 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
|
601 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
602 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
603 cmap = _cmap; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
604 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
605 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
606 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
607 { |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
608 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
|
609 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
610 if (ax.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
611 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
612 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
|
613 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
614 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
615 clim = _clim; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
616 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
617 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
618 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
619 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
620 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
621 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
622 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
623 |
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
|
624 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
|
625 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
|
626 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
627 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
|
628 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
|
629 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
630 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
|
631 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
|
632 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
633 #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
|
634 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
|
635 { \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
636 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
|
637 \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
638 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
|
639 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
|
640 } \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
641 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
|
642 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
652 #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
|
653 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
654 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
655 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
656 |
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
|
657 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
|
658 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
|
659 get_array_limits (const Array<T>& m, double& emin, double& emax, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
660 double& eminp) |
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
|
661 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
662 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
|
663 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
|
664 |
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
|
665 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
|
666 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
667 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
|
668 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
669 // 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
|
670 if (! xisinf (e)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
671 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
672 if (e < emin) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
673 emin = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
674 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
675 if (e > emax) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
676 emax = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
677 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
678 if (e > 0 && e < eminp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
679 eminp = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
680 } |
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
|
681 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
682 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
683 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
684 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
685 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
|
686 caseless_str& rest) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
687 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
688 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
689 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
690 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
691 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
692 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
693 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
694 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
695 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
696 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
697 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
698 offset = 4; |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
699 else if (len >= 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
700 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
701 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
702 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
703 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
704 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
705 else if (len >= 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
706 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
707 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
708 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
709 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
710 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
711 else if (len >= 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
712 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
713 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
714 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
715 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
716 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
717 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
718 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
719 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
720 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
721 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
722 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
723 go_name = pfx; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
724 rest = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
725 result = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
726 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
727 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
728 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
729 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
730 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
731 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
732 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
733 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
|
734 const graphics_handle& h = graphics_handle (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
735 const graphics_handle& p = graphics_handle ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
736 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
737 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
738 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
739 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
740 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
741 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
742 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
743 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
744 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
745 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
746 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
747 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
748 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
749 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
750 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
751 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
752 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
753 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
754 go = new hggroup (h, p); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
755 else if (type.compare ("uimenu")) |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
756 go = new uimenu (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
757 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
758 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
759 |
6406 | 760 // --------------------------------------------------------------------- |
761 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
762 bool |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
763 base_property::set (const octave_value& v, bool do_run ) |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
764 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
765 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
766 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
767 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
768 // Notify graphics toolkit. |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
769 if (id >= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
770 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
771 graphics_object go = gh_manager::get_object (parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
772 if (go) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
773 { |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
774 graphics_toolkit toolkit = go.get_toolkit (); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
775 if (toolkit) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
776 toolkit.update (go, id); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
777 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
778 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
779 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
780 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
781 if (do_run && ! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
782 run_listeners (POSTSET); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
783 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
784 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
785 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
786 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
787 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
788 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
789 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
790 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
791 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
792 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
|
793 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
794 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
|
795 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
796 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
|
797 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
798 gh_manager::execute_callback (parent, l(i), octave_value ()); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
799 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
800 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
801 break; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
802 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
803 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
804 |
6705 | 805 radio_values::radio_values (const std::string& opt_string) |
6406 | 806 { |
6705 | 807 size_t beg = 0; |
808 size_t len = opt_string.length (); | |
809 bool done = len == 0; | |
6681 | 810 |
6705 | 811 while (! done) |
812 { | |
813 size_t end = opt_string.find ('|', beg); | |
6681 | 814 |
6705 | 815 if (end == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
816 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
817 end = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
818 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
819 } |
6681 | 820 |
6705 | 821 std::string t = opt_string.substr (beg, end-beg); |
6681 | 822 |
6705 | 823 // Might want more error checking here... |
824 if (t[0] == '{') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
825 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
826 t = t.substr (1, t.length () - 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
827 default_val = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
828 } |
6705 | 829 else if (beg == 0) // ensure default value |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
830 default_val = t; |
6681 | 831 |
6705 | 832 possible_vals.insert (t); |
6681 | 833 |
6705 | 834 beg = end + 1; |
835 } | |
836 } | |
6681 | 837 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
838 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
839 radio_values::values_as_string (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
840 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
841 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
842 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
|
843 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
844 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
845 if (retval == "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
846 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
847 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
848 retval = "{" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
849 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
850 retval = *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
851 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
852 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
853 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
854 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
855 retval += " | {" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
856 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
857 retval += " | " + *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
858 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
859 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
860 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
861 retval = "[ " + retval + " ]"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
862 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
863 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
864 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
865 Cell |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
866 radio_values::values_as_cell (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
867 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
868 octave_idx_type i = 0; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
869 Cell retval (nelem (), 1); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
870 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
|
871 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
872 retval(i++) = std::string (*it); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
873 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
874 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
875 |
6705 | 876 bool |
6761 | 877 color_values::str2rgb (std::string str) |
6681 | 878 { |
6705 | 879 double tmp_rgb[3] = {0, 0, 0}; |
880 bool retval = true; | |
6761 | 881 unsigned int len = str.length(); |
6681 | 882 |
6925 | 883 std::transform (str.begin (), str.end (), str.begin (), tolower); |
884 | |
6761 | 885 if (str.compare(0, len, "blue", 0, len) == 0) |
886 tmp_rgb[2] = 1; | |
7869 | 887 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
|
888 || str.compare(0, len, "k", 0, len) == 0) |
6761 | 889 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
890 else if (str.compare(0, len, "red", 0, len) == 0) | |
891 tmp_rgb[0] = 1; | |
892 else if (str.compare(0, len, "green", 0, len) == 0) | |
893 tmp_rgb[1] = 1; | |
894 else if (str.compare(0, len, "yellow", 0, len) == 0) | |
895 tmp_rgb[0] = tmp_rgb[1] = 1; | |
896 else if (str.compare(0, len, "magenta", 0, len) == 0) | |
897 tmp_rgb[0] = tmp_rgb[2] = 1; | |
898 else if (str.compare(0, len, "cyan", 0, len) == 0) | |
899 tmp_rgb[1] = tmp_rgb[2] = 1; | |
7869 | 900 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
|
901 || str.compare(0, len, "w", 0, len) == 0) |
6761 | 902 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
|
903 else |
6761 | 904 retval = false; |
6406 | 905 |
6705 | 906 if (retval) |
907 { | |
908 for (int i = 0; i < 3; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
909 xrgb(i) = tmp_rgb[i]; |
6705 | 910 } |
6563 | 911 |
6705 | 912 return retval; |
913 } | |
6681 | 914 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
915 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
916 color_property::do_set (const octave_value& val) |
6790 | 917 { |
918 if (val.is_string ()) | |
919 { | |
920 std::string s = val.string_value (); | |
921 | |
922 if (! s.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
923 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
924 if (radio_val.contains (s)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
925 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
926 if (current_type != radio_t || current_val != s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
927 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
928 current_val = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
929 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
930 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
931 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
932 } |
6790 | 933 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
934 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
935 color_values col (s); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
936 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
937 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
938 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
939 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
940 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
941 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
942 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
943 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
944 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
945 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
946 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
|
947 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
|
948 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
949 } |
6790 | 950 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
951 error ("invalid value for color property \"%s\"", |
7363 | 952 get_name ().c_str ()); |
6790 | 953 } |
9311
868fbeb2e365
allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents:
9238
diff
changeset
|
954 else if (val.is_numeric_type ()) |
6790 | 955 { |
956 Matrix m = val.matrix_value (); | |
957 | |
958 if (m.numel () == 3) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
959 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
960 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
|
961 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
962 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
963 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
964 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
965 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
966 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
967 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
968 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
969 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
970 } |
6790 | 971 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
972 error ("invalid value for color property \"%s\"", |
7363 | 973 get_name ().c_str ()); |
6790 | 974 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
975 else |
7363 | 976 error ("invalid value for color property \"%s\"", |
977 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
978 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
979 return false; |
6790 | 980 } |
981 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
982 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
983 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
|
984 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
985 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
986 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
987 std::string s = val.string_value (); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
988 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
989 if (! s.empty () && radio_val.contains (s)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
990 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
991 if (current_type != radio_t || s != current_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
992 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
993 current_val = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
994 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
995 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
996 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
997 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
998 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
999 error ("invalid value for double_radio property \"%s\"", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1000 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
|
1001 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1002 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
|
1003 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1004 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1005 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1006 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
|
1007 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1008 dval = new_dval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1009 current_type = double_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1010 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1011 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1012 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1013 else |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1014 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
|
1015 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1016 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1017 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1018 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1019 |
7363 | 1020 bool |
1021 array_property::validate (const octave_value& v) | |
1022 { | |
7364 | 1023 bool xok = false; |
7363 | 1024 |
8333 | 1025 // 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
|
1026 if (v.is_empty () && v.is_numeric_type ()) |
7363 | 1027 return true; |
1028 | |
1029 // check value type | |
1030 if (type_constraints.size () > 0) | |
1031 { | |
1032 for (std::list<std::string>::const_iterator it = type_constraints.begin (); | |
7364 | 1033 ! 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
|
1034 if ((*it) == v.class_name ()) |
7364 | 1035 xok = true; |
7363 | 1036 } |
1037 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
|
1038 xok = v.is_numeric_type (); |
7363 | 1039 |
7364 | 1040 if (xok) |
7363 | 1041 { |
1042 dim_vector vdims = v.dims (); | |
1043 int vlen = vdims.length (); | |
1044 | |
7364 | 1045 xok = false; |
7363 | 1046 |
1047 // check value size | |
1048 if (size_constraints.size () > 0) | |
1049 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); | |
7364 | 1050 ! xok && it != size_constraints.end (); ++it) |
7363 | 1051 { |
1052 dim_vector itdims = (*it); | |
1053 | |
1054 if (itdims.length () == vlen) | |
1055 { | |
7364 | 1056 xok = true; |
7363 | 1057 |
7364 | 1058 for (int i = 0; xok && i < vlen; i++) |
7363 | 1059 if (itdims(i) >= 0 && itdims(i) != vdims(i)) |
7364 | 1060 xok = false; |
7363 | 1061 } |
1062 } | |
1063 else | |
1064 return true; | |
1065 } | |
1066 | |
7364 | 1067 return xok; |
7363 | 1068 } |
1069 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1070 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1071 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1072 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1073 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1074 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1075 if (data.dims () == v.dims ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1076 { |
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
|
1077 |
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
|
1078 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1079 { \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1080 if (data.numel () == 1) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1081 return data.F ## scalar_value () == \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1082 v.F ## scalar_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1083 else \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1084 { \ |
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
|
1085 /* 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
|
1086 /* that are converted, to not be deallocated early */ \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1087 const A m1 = data.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1088 const T* d1 = m1.data (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1089 const A m2 = v.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1090 const T* d2 = m2.data ();\ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1091 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1092 bool flag = true; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1093 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1094 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
|
1095 if (d1[i] != d2[i]) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1096 flag = false; \ |
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 return flag; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1099 } \ |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1102 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
|
1103 CHECK_ARRAY_EQUAL (double, , NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1104 else if (data.is_single_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1105 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1106 else if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1107 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1108 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1109 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1110 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1111 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1112 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1113 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1114 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1115 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1116 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1117 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1118 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1119 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1120 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1121 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1122 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1123 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1124 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1125 return false; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1126 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1127 |
7363 | 1128 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
|
1129 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
|
1130 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1131 xmin = xminp = octave_Inf; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1132 xmax = -octave_Inf; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1133 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1134 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
|
1135 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1136 if (data.is_integer_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1137 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1138 if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1139 get_array_limits (data.int8_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1140 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1141 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1142 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1143 get_array_limits (data.int16_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1144 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1145 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1146 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1147 get_array_limits (data.int32_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1148 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1149 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1150 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1151 get_array_limits (data.int64_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1152 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1153 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1154 } |
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
|
1155 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1156 get_array_limits (data.array_value (), xmin, xmax, xminp); |
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
|
1157 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1158 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1159 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1160 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1161 handle_property::do_set (const octave_value& v) |
7363 | 1162 { |
1163 double dv = v.double_value (); | |
1164 | |
1165 if (! error_state) | |
1166 { | |
1167 graphics_handle gh = gh_manager::lookup (dv); | |
1168 | |
1169 if (xisnan (gh.value ()) || gh.ok ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1170 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1171 if (current_val != gh) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1172 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1173 current_val = gh; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1174 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1175 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1176 } |
7363 | 1177 else |
1178 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
|
1179 dv, get_name ().c_str ()); |
7363 | 1180 } |
1181 else | |
1182 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
|
1183 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1184 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1185 return false; |
7363 | 1186 } |
1187 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1188 Matrix |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1189 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
|
1190 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1191 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
|
1192 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
|
1193 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1194 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
|
1195 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1196 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
|
1197 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
|
1198 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1199 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
|
1200 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1201 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
|
1202 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
|
1203 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1204 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
|
1205 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1206 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
|
1207 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1208 if (! return_hidden) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1209 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1210 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1211 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
|
1212 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1213 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1214 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1215 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
|
1216 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1217 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1218 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1219 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
|
1220 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
|
1221 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1222 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1223 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1224 return retval; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1225 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1226 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1227 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1228 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
|
1229 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1230 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
|
1231 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
|
1232 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1233 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
|
1234 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1235 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
|
1236 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
|
1237 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1238 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1239 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1240 if (clear) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1241 children_list.clear (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1242 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1243 |
7363 | 1244 bool |
7367 | 1245 callback_property::validate (const octave_value& v) const |
7363 | 1246 { |
7367 | 1247 // case 1: function handle |
1248 // case 2: cell array with first element being a function handle | |
1249 // case 3: string corresponding to known function name | |
1250 // case 4: evaluatable string | |
1251 // case 5: empty matrix | |
1252 | |
1253 if (v.is_function_handle ()) | |
1254 return true; | |
1255 else if (v.is_string ()) | |
1256 // complete validation will be done at execution-time | |
1257 return true; | |
1258 else if (v.is_cell () && v.length () > 0 | |
1259 && (v.rows() == 1 || v.columns () == 1) | |
1260 && v.cell_value ()(0).is_function_handle ()) | |
1261 return true; | |
1262 else if (v.is_empty ()) | |
1263 return true; | |
1264 | |
1265 return false; | |
7363 | 1266 } |
1267 | |
1268 void | |
7367 | 1269 callback_property::execute (const octave_value& data) const |
7363 | 1270 { |
7367 | 1271 if (callback.is_defined () && ! callback.is_empty ()) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
1272 gh_manager::execute_callback (get_parent (), callback, data); |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1273 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1274 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1275 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1276 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1277 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
|
1278 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1279 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1280 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
|
1281 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
|
1282 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1283 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1284 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1285 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1286 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1287 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
|
1288 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1289 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1290 retval = property (new string_property (name, h, val)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1291 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1292 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1293 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1294 octave_value val = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1295 (args.length () > 0 ? args(0) : octave_value (Matrix ())); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1296 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1297 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1298 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1299 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1300 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1301 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1302 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1303 std::string vals = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1304 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1305 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1306 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1307 retval = property (new radio_property (name, h, vals)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1308 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1309 if (args.length () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1310 retval.set (args(1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1311 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1312 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1313 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
|
1314 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1315 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1316 error ("addproperty: missing possible values for radio property"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1317 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1318 else if (type.compare ("double")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1319 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1320 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
|
1321 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1322 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1323 retval = property (new double_property (name, h, d)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1324 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1325 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1326 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1327 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
|
1328 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1329 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1331 graphics_handle gh (hh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1332 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1333 retval = property (new handle_property (name, h, gh)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1334 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1335 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1336 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1337 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1338 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1339 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1340 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1341 retval.set (args(0)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1342 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1343 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1344 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1345 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1346 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1347 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1348 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1349 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1350 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1351 // FIXME -- additional argument could define constraints, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1352 // but is this really useful? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1353 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1354 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1355 else if (type.compare ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1356 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1357 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1358 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1359 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1360 if (args.length () > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1361 rv = radio_values (args(1).string_value ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1362 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1363 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1364 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1365 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
|
1366 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1367 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1368 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1369 if (args.length () > 0 && ! args(0).is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1370 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1371 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1372 retval.set (rv.default_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1373 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1374 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1375 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1376 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1377 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1378 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1379 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1380 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
|
1381 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1382 graphics_object go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1383 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1384 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
|
1385 dprop_obj_map.find (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1386 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1387 if (it == dprop_obj_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1388 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1389 base_graphics_object *bgo = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1390 make_graphics_object_from_type (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1391 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1392 if (bgo) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1393 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1394 go = graphics_object (bgo); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1395 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1396 dprop_obj_map[go_name] = go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1397 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1398 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1399 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1400 go = it->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1401 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1402 if (go.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1403 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1404 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
|
1405 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1406 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1407 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1408 retval = prop.clone (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1409 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1410 retval.set_parent (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1411 retval.set_name (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1412 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1413 if (args.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1414 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1415 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1416 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1417 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1418 error ("addproperty: invalid object type (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1419 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1420 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1421 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1422 error ("addproperty: unsupported type for dynamic property (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1423 type.c_str ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1424 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1425 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1426 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1427 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1428 |
7363 | 1429 // --------------------------------------------------------------------- |
6681 | 1430 |
6705 | 1431 void |
7189 | 1432 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1433 { |
6705 | 1434 size_t offset = 0; |
6681 | 1435 |
6705 | 1436 size_t len = name.length (); |
6681 | 1437 |
6705 | 1438 if (len > 4) |
1439 { | |
7189 | 1440 caseless_str pfx = name.substr (0, 4); |
6681 | 1441 |
6705 | 1442 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1443 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1444 offset = 4; |
6705 | 1445 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1446 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1447 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1448 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1449 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1450 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1451 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1452 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1453 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1454 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1455 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1456 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1457 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1458 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1459 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1460 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1461 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1462 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1463 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1464 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1465 } |
6681 | 1466 |
6705 | 1467 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1468 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1469 // 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
|
1470 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1471 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1472 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1473 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
|
1474 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
|
1475 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1476 bool has_property = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1477 if (pfx == "axes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1478 has_property = axes::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1479 else if (pfx == "line") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1480 has_property = line::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1481 else if (pfx == "text") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1482 has_property = text::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1483 else if (pfx == "image") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1484 has_property = image::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1485 else if (pfx == "patch") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1486 has_property = patch::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1487 else if (pfx == "figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1488 has_property = figure::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1489 else if (pfx == "surface") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1490 has_property = surface::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1491 else if (pfx == "hggroup") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1492 has_property = hggroup::properties::has_core_property (pname); |
11283 | 1493 else if (pfx == "uimenu") |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1494 has_property = uimenu::properties::has_core_property (pname); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1495 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1496 if (has_property) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1497 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1498 bool remove = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1499 if (val.is_string ()) |
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 caseless_str tval = val.string_value (); |
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 remove = tval.compare ("remove"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1504 } |
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 pval_map_type& pval_map = plist_map[pfx]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1507 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1508 if (remove) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1509 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1510 pval_map_iterator p = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1511 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1512 if (p != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1513 pval_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1514 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1515 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1516 pval_map[pname] = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1517 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1518 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1519 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
|
1520 } |
6705 | 1521 } |
6406 | 1522 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
1523 if (! error_state && offset == 0) |
6705 | 1524 error ("invalid default property specification"); |
1525 } | |
6406 | 1526 |
6705 | 1527 octave_value |
7189 | 1528 property_list::lookup (const caseless_str& name) const |
6705 | 1529 { |
1530 octave_value retval; | |
6406 | 1531 |
6705 | 1532 size_t offset = 0; |
6406 | 1533 |
6705 | 1534 size_t len = name.length (); |
6406 | 1535 |
6705 | 1536 if (len > 4) |
1537 { | |
7189 | 1538 caseless_str pfx = name.substr (0, 4); |
6406 | 1539 |
6705 | 1540 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1541 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1542 offset = 4; |
6705 | 1543 else if (len > 5) |
10315
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 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1546 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1547 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1548 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1549 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1550 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1551 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1552 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1553 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1554 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1555 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1556 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1557 pfx = name.substr (0, 7); |
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 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1560 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1561 } |
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 } |
6406 | 1564 |
6705 | 1565 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1566 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1567 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1568 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1569 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
|
1570 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
|
1571 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1572 plist_map_const_iterator p = find (pfx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1573 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1574 if (p != end ()) |
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 const pval_map_type& pval_map = p->second; |
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 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
|
1579 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1580 if (q != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1581 retval = q->second; |
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 } |
6705 | 1584 } |
6406 | 1585 |
6705 | 1586 return retval; |
1587 } | |
6406 | 1588 |
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
|
1589 octave_scalar_map |
6705 | 1590 property_list::as_struct (const std::string& prefix_arg) const |
1591 { | |
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
|
1592 octave_scalar_map m; |
6406 | 1593 |
6705 | 1594 for (plist_map_const_iterator p = begin (); p != end (); p++) |
1595 { | |
1596 std::string prefix = prefix_arg + p->first; | |
6406 | 1597 |
6705 | 1598 const pval_map_type pval_map = p->second; |
6406 | 1599 |
6705 | 1600 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
|
1601 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1602 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1603 m.assign (prefix + q->first, q->second); |
6705 | 1604 } |
6406 | 1605 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1606 return m; |
6705 | 1607 } |
6432 | 1608 |
6874 | 1609 graphics_handle::graphics_handle (const octave_value& a) |
1610 : val (octave_NaN) | |
1611 { | |
1612 if (a.is_empty ()) | |
1613 /* do nothing */; | |
1614 else | |
1615 { | |
1616 double tval = a.double_value (); | |
1617 | |
1618 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1619 val = tval; |
6874 | 1620 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1621 error ("invalid graphics handle"); |
6874 | 1622 } |
1623 } | |
1624 | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1625 // 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
|
1626 |
6705 | 1627 void |
1628 graphics_object::set (const octave_value_list& args) | |
1629 { | |
1630 int nargin = args.length (); | |
6406 | 1631 |
6705 | 1632 if (nargin == 0) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1633 error ("graphics_object::set: Nothing to set"); |
6705 | 1634 else if (nargin % 2 == 0) |
1635 { | |
1636 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
|
1637 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1638 caseless_str name = args(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1639 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1640 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1641 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1642 octave_value val = args(i+1); |
6406 | 1643 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1644 set_value_or_default (name, val); |
6406 | 1645 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1646 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1647 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1648 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1649 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1650 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
|
1651 } |
6705 | 1652 } |
1653 else | |
1654 error ("set: invalid number of arguments"); | |
1655 } | |
6406 | 1656 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1657 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1658 %!# 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
|
1659 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1660 %! set(gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1661 %! 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
|
1662 %! 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
|
1663 %! 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
|
1664 %! 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
|
1665 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1666 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1667 // 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
|
1668 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1669 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
|
1670 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
|
1671 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1672 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
|
1673 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1674 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
|
1675 names.numel (), values.columns ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1676 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1677 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1678 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
|
1679 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1680 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
|
1681 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1682 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
|
1683 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
|
1684 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1685 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
|
1686 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1687 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1688 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1689 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1690 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1691 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1692 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1693 %!# 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
|
1694 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1695 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1696 %! 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
|
1697 %! 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
|
1698 %! 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
|
1699 %! 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
|
1700 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1701 %!# 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
|
1702 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1703 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1704 %! 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
|
1705 %! 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
|
1706 %! 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
|
1707 %! 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
|
1708 %! 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
|
1709 %! 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
|
1710 %! 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
|
1711 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1712 %!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
|
1713 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1714 %! 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
|
1715 %! 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
|
1716 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1717 %!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
|
1718 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1719 %! 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
|
1720 %! 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
|
1721 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1722 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1723 // 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
|
1724 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
|
1725 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
|
1726 { |
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
|
1727 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
|
1728 p != m.end (); p++) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1729 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1730 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
|
1731 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1732 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
|
1733 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1734 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
|
1735 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1736 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1737 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1738 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1739 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1740 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1741 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1742 %!# 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
|
1743 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1744 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1745 %! 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
|
1746 %! 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
|
1747 %! 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
|
1748 %! 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
|
1749 %! 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
|
1750 %! 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
|
1751 %! 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
|
1752 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1753 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1754 // 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
|
1755 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1756 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1757 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
|
1758 const octave_value& val) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1759 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1760 if (val.is_string ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1761 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1762 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
|
1763 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1764 octave_value default_val; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1765 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1766 if (tval.compare ("default")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1767 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1768 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
|
1769 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1770 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1771 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1772 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1773 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
|
1774 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1775 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
|
1776 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1777 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
|
1778 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1779 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1780 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1781 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1782 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
|
1783 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1784 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1785 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1786 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1787 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1788 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1789 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1790 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1791 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1792 %!# 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
|
1793 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1794 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1795 %! 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
|
1796 %! set (0, "defaultlinelinewidth", 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1797 %! set (h, "linewidth", "default"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1798 %! 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
|
1799 %! set (h, "linewidth", "factory"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1800 %! 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
|
1801 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1802 |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1803 static double |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1804 make_handle_fraction (void) |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1805 { |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1806 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
|
1807 |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1808 return (rand () + 1.0) / maxrand; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1809 } |
6406 | 1810 |
6705 | 1811 graphics_handle |
1812 gh_manager::get_handle (const std::string& go_name) | |
1813 { | |
1814 graphics_handle retval; | |
6406 | 1815 |
6705 | 1816 if (go_name == "figure") |
1817 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1818 // 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
|
1819 // figure number. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1820 |
6705 | 1821 // We always want the lowest unused figure number. |
6406 | 1822 |
6705 | 1823 retval = 1; |
6425 | 1824 |
6705 | 1825 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
|
1826 retval++; |
6705 | 1827 } |
1828 else | |
1829 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1830 // 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
|
1831 // 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
|
1832 // 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
|
1833 // time. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1834 |
6705 | 1835 free_list_iterator p = handle_free_list.begin (); |
6406 | 1836 |
6705 | 1837 if (p != handle_free_list.end ()) |
10315
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 retval = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1840 handle_free_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1841 } |
6705 | 1842 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1843 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1844 retval = graphics_handle (next_handle); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1845 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
1846 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
|
1847 } |
6705 | 1848 } |
6406 | 1849 |
6705 | 1850 return retval; |
1851 } | |
6406 | 1852 |
6705 | 1853 void |
1854 gh_manager::do_free (const graphics_handle& h) | |
1855 { | |
7056 | 1856 if (h.ok ()) |
6705 | 1857 { |
6874 | 1858 if (h.value () != 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1859 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1860 iterator p = handle_map.find (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1861 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1862 if (p != handle_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1863 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1864 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
|
1865 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1866 bp.set_beingdeleted (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1867 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1868 bp.delete_children (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1869 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1870 octave_value val = bp.get_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1871 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1872 bp.execute_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1873 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1874 // Notify graphics toolkit. |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1875 graphics_toolkit toolkit = p->second.get_toolkit (); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1876 if (toolkit) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
1877 toolkit.finalize (p->second); |
8208 | 1878 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1879 // 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
|
1880 // 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
|
1881 // unknown graphics toolkit. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1882 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1883 // Graphics handles for non-figure objects are negative |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1884 // integers plus some random fractional part. To avoid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1885 // 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
|
1886 // 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
|
1887 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1888 handle_map.erase (p); |
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 if (h.value () < 0) |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
1891 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
|
1892 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1893 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1894 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
|
1895 } |
6705 | 1896 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1897 error ("graphics_handle::free: can't delete root figure"); |
6705 | 1898 } |
1899 } | |
6406 | 1900 |
1901 gh_manager *gh_manager::instance = 0; | |
1902 | |
1903 static void | |
7189 | 1904 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 1905 const octave_value& val) |
1906 { | |
1907 graphics_object obj = gh_manager::get_object (h); | |
1908 obj.set (name, val); | |
1909 } | |
1910 | |
1911 static void | |
1912 xset (const graphics_handle& h, const octave_value_list& args) | |
1913 { | |
1914 if (args.length () > 0) | |
1915 { | |
1916 graphics_object obj = gh_manager::get_object (h); | |
1917 obj.set (args); | |
1918 } | |
1919 } | |
1920 | |
1921 static octave_value | |
7189 | 1922 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 1923 { |
1924 graphics_object obj = gh_manager::get_object (h); | |
1925 return obj.get (name); | |
1926 } | |
1927 | |
1928 static graphics_handle | |
1929 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
|
1930 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
|
1931 bool adopt = true) |
6406 | 1932 { |
1933 graphics_handle h = octave_NaN; | |
1934 | |
1935 double val = ov.double_value (); | |
1936 | |
1937 if (! error_state) | |
1938 { | |
1939 h = gh_manager::lookup (val); | |
1940 | |
7056 | 1941 if (h.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1942 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1943 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
|
1944 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1945 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1946 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1947 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
|
1948 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1949 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1950 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1951 if (adopt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1952 obj.set ("parent", new_parent.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1953 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1954 obj.reparent (new_parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1955 } |
6406 | 1956 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1957 error ("%s: invalid graphics handle (= %g) for %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1958 who.c_str (), val, property.c_str ()); |
6406 | 1959 } |
1960 else | |
1961 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
|
1962 who.c_str (), property.c_str ()); |
6406 | 1963 |
1964 return h; | |
1965 } | |
1966 | |
1967 // This function is NOT equivalent to the scripting language function gcf. | |
1968 graphics_handle | |
1969 gcf (void) | |
1970 { | |
1971 octave_value val = xget (0, "currentfigure"); | |
1972 | |
1973 return val.is_empty () ? octave_NaN : val.double_value (); | |
1974 } | |
1975 | |
1976 // This function is NOT equivalent to the scripting language function gca. | |
1977 graphics_handle | |
1978 gca (void) | |
1979 { | |
1980 octave_value val = xget (gcf (), "currentaxes"); | |
1981 | |
1982 return val.is_empty () ? octave_NaN : val.double_value (); | |
1983 } | |
1984 | |
1985 static void | |
1986 adopt (const graphics_handle& p, const graphics_handle& h) | |
1987 { | |
1988 graphics_object parent_obj = gh_manager::get_object (p); | |
1989 parent_obj.adopt (h); | |
1990 } | |
1991 | |
1992 static bool | |
7056 | 1993 is_handle (const graphics_handle& h) |
1994 { | |
1995 return h.ok (); | |
1996 } | |
1997 | |
1998 static bool | |
6406 | 1999 is_handle (double val) |
2000 { | |
6874 | 2001 graphics_handle h = gh_manager::lookup (val); |
2002 | |
2003 return h.ok (); | |
6406 | 2004 } |
2005 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2006 static octave_value |
6406 | 2007 is_handle (const octave_value& val) |
2008 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2009 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2010 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2011 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
|
2012 retval = true; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2013 else if (val.is_real_matrix ()) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2014 { |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2015 if (val.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2016 retval = boolNDArray (val.dims (), false); |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2017 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2018 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2019 const NDArray handles = val.array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2020 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2021 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2022 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2023 boolNDArray result (handles.dims ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2024 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2025 for (octave_idx_type i = 0; i < handles.numel (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2026 result.xelem (i) = is_handle (handles (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2027 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2028 retval = result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2029 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2030 } |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2031 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2032 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2033 return retval; |
6406 | 2034 } |
2035 | |
2036 static bool | |
2037 is_figure (double val) | |
2038 { | |
2039 graphics_object obj = gh_manager::get_object (val); | |
2040 | |
2041 return obj && obj.isa ("figure"); | |
2042 } | |
2043 | |
7370 | 2044 static void |
2045 xcreatefcn (const graphics_handle& h) | |
2046 { | |
2047 graphics_object obj = gh_manager::get_object (h); | |
2048 obj.get_properties ().execute_createfcn (); | |
2049 } | |
2050 | |
6406 | 2051 // --------------------------------------------------------------------- |
2052 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2053 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2054 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
|
2055 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2056 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2057 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2058 update (go, id); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2059 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2060 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2061 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2062 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
|
2063 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2064 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2065 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2066 initialize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2067 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2068 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2069 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2070 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
|
2071 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2072 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2073 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2074 finalize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2075 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2076 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2077 |
6705 | 2078 void |
2079 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
|
2080 property_list& defaults) |
6406 | 2081 { |
6705 | 2082 std::string go_name = graphics_object_name (); |
6406 | 2083 |
6705 | 2084 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 2085 |
6705 | 2086 if (p != defaults.end ()) |
2087 { | |
2088 const property_list::pval_map_type pval_map = p->second; | |
6406 | 2089 |
6705 | 2090 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
|
2091 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2092 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2093 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2094 std::string pname = q->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2095 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2096 obj.set (pname, q->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2097 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2098 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2099 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2100 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
|
2101 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2102 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2103 } |
6705 | 2104 } |
2105 } | |
6406 | 2106 |
7363 | 2107 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2108 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 2109 { |
2110 octave_value retval; | |
2111 | |
8090 | 2112 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
|
2113 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2114 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2115 retval = it->second.get (); |
7363 | 2116 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2117 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 2118 |
2119 return retval; | |
2120 } | |
2121 | |
2122 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2123 base_properties::get_dynamic (bool all) const |
7363 | 2124 { |
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
|
2125 octave_scalar_map m; |
7363 | 2126 |
8090 | 2127 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin (); |
7363 | 2128 it != all_props.end (); ++it) |
7379 | 2129 if (all || ! it->second.is_hidden ()) |
2130 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 2131 |
2132 return m; | |
2133 } | |
2134 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2135 std::set<std::string> |
9972 | 2136 base_properties::dynamic_property_names (void) const |
2137 { | |
2138 return dynamic_properties; | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2139 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2140 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2141 bool |
9972 | 2142 base_properties::has_dynamic_property (const std::string& pname) |
2143 { | |
2144 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
|
2145 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2146 return dynprops.find (pname) != dynprops.end (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2147 } |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2148 |
7363 | 2149 void |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2150 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
|
2151 const octave_value& val) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2152 { |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2153 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
|
2154 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2155 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2156 it->second.set (val); |
7363 | 2157 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2158 error ("set: unknown property \"%s\"", pname.c_str ()); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2159 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2160 if (! error_state) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2161 { |
9972 | 2162 dynamic_properties.insert (pname); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2163 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2164 mark_modified (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2165 } |
7363 | 2166 } |
2167 | |
2168 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2169 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 2170 { |
8090 | 2171 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
|
2172 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2173 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2174 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2175 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2176 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2177 } |
7363 | 2178 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2179 return it->second; |
7363 | 2180 } |
2181 | |
6705 | 2182 void |
6836 | 2183 base_properties::set_parent (const octave_value& val) |
6705 | 2184 { |
2185 double tmp = val.double_value (); | |
6406 | 2186 |
6705 | 2187 graphics_handle new_parent = octave_NaN; |
6406 | 2188 |
6705 | 2189 if (! error_state) |
2190 { | |
2191 new_parent = gh_manager::lookup (tmp); | |
6406 | 2192 |
7056 | 2193 if (new_parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2194 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2195 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
|
2196 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2197 parent_obj.remove_child (__myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2198 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2199 parent = new_parent.as_octave_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2200 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2201 ::adopt (parent.handle_value (), __myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2202 } |
6705 | 2203 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2204 error ("set: invalid graphics handle (= %g) for parent", tmp); |
6705 | 2205 } |
2206 else | |
2207 error ("set: expecting parent to be a graphics handle"); | |
2208 } | |
6432 | 2209 |
6705 | 2210 void |
6836 | 2211 base_properties::mark_modified (void) |
2212 { | |
7363 | 2213 __modified__ = "on"; |
2214 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 2215 if (parent_obj) |
2216 parent_obj.mark_modified (); | |
6836 | 2217 } |
2218 | |
2219 void | |
2220 base_properties::override_defaults (base_graphics_object& obj) | |
2221 { | |
7363 | 2222 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
|
2223 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2224 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2225 parent_obj.override_defaults (obj); |
6836 | 2226 } |
2227 | |
2228 void | |
7214 | 2229 base_properties::update_axis_limits (const std::string& axis_type) const |
2230 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2231 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
|
2232 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2233 if (obj) |
7214 | 2234 obj.update_axis_limits (axis_type); |
2235 } | |
2236 | |
2237 void | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2238 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
|
2239 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
|
2240 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2241 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
|
2242 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2243 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2244 obj.update_axis_limits (axis_type, h); |
6836 | 2245 } |
2246 | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2247 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2248 base_properties::get_toolkit (void) const |
7419 | 2249 { |
2250 graphics_object go = gh_manager::get_object (get_parent ()); | |
2251 | |
2252 if (go) | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2253 return go.get_toolkit (); |
7419 | 2254 else |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2255 return graphics_toolkit (); |
7419 | 2256 } |
2257 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2258 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2259 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
|
2260 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2261 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
|
2262 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2263 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
|
2264 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2265 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
|
2266 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2267 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2268 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
|
2269 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2270 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2271 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2272 void |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2273 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
|
2274 listener_mode mode) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2275 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2276 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2277 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2278 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2279 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2280 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2281 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2282 void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2283 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
|
2284 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
|
2285 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2286 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
|
2287 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2288 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
|
2289 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
|
2290 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2291 |
7363 | 2292 // --------------------------------------------------------------------- |
2293 | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2294 class gnuplot_toolkit : public base_graphics_toolkit |
7408 | 2295 { |
2296 public: | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2297 gnuplot_toolkit (void) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2298 : base_graphics_toolkit ("gnuplot") { } |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2299 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2300 ~gnuplot_toolkit (void) { } |
7408 | 2301 |
2302 bool is_valid (void) const { return true; } | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2303 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2304 void finalize (const graphics_object& go) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2305 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2306 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2307 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2308 const figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2309 dynamic_cast<const figure::properties&> (go.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2310 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2311 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2312 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2313 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2314 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2315 void update (const graphics_object& go, int id) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2316 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2317 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2318 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2319 graphics_object obj (go); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2320 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2321 figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2322 dynamic_cast<figure::properties&> (obj.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2323 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2324 switch (id) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2325 { |
11239
5fa7667f90e5
Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents:
11175
diff
changeset
|
2326 case base_properties::ID_VISIBLE: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2327 if (! props.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2328 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2329 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2330 props.set___plot_stream__ (Matrix ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2331 props.set___enhanced__ (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2332 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2333 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2334 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2335 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2336 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2337 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2338 void redraw_figure (const graphics_object& go) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2339 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2340 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2341 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2342 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2343 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2344 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2345 void print_figure (const graphics_object& go, const std::string& term, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2346 const std::string& file, bool mono, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2347 const std::string& debug_file) const |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2348 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2349 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2350 if (! debug_file.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2351 args(4) = debug_file; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2352 args(3) = mono; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2353 args(2) = file; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2354 args(1) = term; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2355 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2356 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2357 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2358 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2359 Matrix get_canvas_size (const graphics_handle&) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2360 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2361 Matrix sz (1, 2, 0.0); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2362 return sz; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2363 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2364 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2365 double get_screen_resolution (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2366 { return 72.0; } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2367 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2368 Matrix get_screen_size (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2369 { return Matrix (1, 2, 0.0); } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2370 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2371 private: |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2372 void send_quit (const octave_value& pstream) const |
7408 | 2373 { |
9561
c60a9e1a0372
try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents:
9455
diff
changeset
|
2374 if (! pstream.is_empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2375 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2376 octave_value_list args; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2377 Matrix fids = pstream.matrix_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2378 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2379 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2380 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2381 args(1) = "\nquit;\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2382 args(0) = fids(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2383 feval ("fputs", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2384 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2385 args.resize (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2386 feval ("fflush", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2387 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2388 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2389 if (fids.numel () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2390 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2391 args(0) = fids(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2392 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2393 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2394 if (fids.numel () > 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2395 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2396 args(0) = fids(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2397 feval ("waitpid", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2398 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2399 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2400 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2401 } |
7408 | 2402 } |
2403 }; | |
2404 | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2405 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2406 graphics_toolkit::default_toolkit (void) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2407 { |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2408 if (available_toolkits.size () == 0) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2409 register_toolkit (new gnuplot_toolkit ()); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2410 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2411 return available_toolkits["gnuplot"]; |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2412 } |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2413 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2414 std::map<std::string, graphics_toolkit> graphics_toolkit::available_toolkits; |
7408 | 2415 |
2416 // --------------------------------------------------------------------- | |
2417 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2418 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2419 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
|
2420 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2421 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
|
2422 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2423 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
|
2424 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2425 if (parent_obj) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2426 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
|
2427 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2428 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2429 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
|
2430 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2431 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2432 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2433 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
|
2434 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
|
2435 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2436 if (valid_object ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2437 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2438 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
|
2439 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2440 if (parent_obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2441 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
|
2442 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2443 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2444 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
|
2445 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2446 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2447 void |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2448 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
|
2449 { |
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
|
2450 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
|
2451 |
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
|
2452 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
|
2453 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2454 // 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
|
2455 // 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
|
2456 // 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
|
2457 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2458 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2459 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2460 frame.protect_var (discard_error_messages); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2461 frame.protect_var (error_state); |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2462 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2463 discard_error_messages = true; |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2464 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2465 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
|
2466 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2467 if (! error_state && p.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2468 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
|
2469 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2470 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2471 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2472 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2473 base_graphics_object::values_as_string (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2474 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2475 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2476 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2477 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2478 { |
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
|
2479 octave_map m = get ().map_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2480 |
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
|
2481 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
|
2482 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2483 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2484 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2485 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2486 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2487 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2488 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2489 retval += "\n\t" + std::string (pa->first) + ": "; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2490 if (p.is_radio ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2491 retval += p.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2492 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2493 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2494 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2495 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2496 retval += "\n"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2497 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2498 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2499 error ("base_graphics_object::values_as_string: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2500 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2501 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2502 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2503 |
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
|
2504 octave_scalar_map |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2505 base_graphics_object::values_as_struct (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2506 { |
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
|
2507 octave_scalar_map retval; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2508 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2509 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2510 { |
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
|
2511 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
|
2512 |
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
|
2513 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
|
2514 pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2515 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2516 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2517 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2518 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2519 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2520 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2521 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2522 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
|
2523 retval.assign (p.get_name (), p.values_as_cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2524 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
|
2525 retval.assign (p.get_name (), Cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2526 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2527 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2528 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2529 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2530 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2531 error ("base_graphics_object::values_as_struct: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2532 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2533 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2534 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2535 |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2536 graphics_object |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2537 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
|
2538 { |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2539 if (valid_object ()) |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2540 { |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2541 if (isa (obj_type)) |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2542 return *this; |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2543 else |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2544 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
|
2545 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2546 else |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2547 return graphics_object (); |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2548 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2549 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2550 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2551 |
7363 | 2552 #include "graphics-props.cc" |
2553 | |
2554 // --------------------------------------------------------------------- | |
2555 | |
6836 | 2556 void |
7363 | 2557 root_figure::properties::set_currentfigure (const octave_value& v) |
6874 | 2558 { |
7378 | 2559 graphics_handle val (v); |
7363 | 2560 |
6874 | 2561 if (error_state) |
2562 return; | |
2563 | |
7059 | 2564 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2565 { |
2566 currentfigure = val; | |
2567 | |
7363 | 2568 gh_manager::push_figure (val); |
6874 | 2569 } |
2570 else | |
2571 gripe_set_invalid ("currentfigure"); | |
2572 } | |
2573 | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2574 void |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2575 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
|
2576 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2577 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2578 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2579 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2580 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2581 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2582 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2583 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2584 if (! cbo_stack.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2585 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2586 val = cbo_stack.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2587 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2588 cbo_stack.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2589 } |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2590 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2591 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2592 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2593 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2594 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2595 if (get_callbackobject ().ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2596 cbo_stack.push_front (get_callbackobject ()); |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2597 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2598 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2599 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2600 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2601 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2602 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2603 |
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
|
2604 // 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
|
2605 // 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
|
2606 // aren't set yet. |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2607 void |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2608 root_figure::properties::update_units (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2609 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2610 caseless_str xunits = get_units (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2611 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2612 Matrix ss = default_screensize (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2613 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2614 double dpi = get_screenpixelsperinch (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2615 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2616 if (xunits.compare ("inches")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2617 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2618 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2619 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2620 ss(2) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2621 ss(3) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2622 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2623 else if (xunits.compare ("centimeters")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2624 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2625 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2626 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2627 ss(2) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2628 ss(3) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2629 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2630 else if (xunits.compare ("normalized")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2631 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2632 ss = Matrix (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2633 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2634 else if (xunits.compare ("points")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2635 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2636 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2637 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2638 ss(2) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2639 ss(3) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2640 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2641 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2642 set_screensize (ss); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2643 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2644 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2645 void |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2646 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
|
2647 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2648 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2649 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2650 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2651 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2652 xset (0, "currentfigure", cf.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2653 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2654 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2655 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2656 |
6406 | 2657 property_list |
2658 root_figure::factory_properties = root_figure::init_factory_properties (); | |
2659 | |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2660 static void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2661 reset_default_properties (property_list& default_properties) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2662 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2663 property_list new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2664 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2665 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
|
2666 p != default_properties.end (); p++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2667 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2668 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
|
2669 std::string prefix = p->first; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2670 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2671 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
|
2672 q != pval_map.end (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2673 q++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2674 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2675 std::string s = q->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2676 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2677 if (prefix == "axes" && (s == "position" || s == "units")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2678 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
|
2679 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
|
2680 || s == "windowstyle" |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2681 || s == "paperunits")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2682 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2683 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2684 } |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2685 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2686 default_properties = new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2687 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2688 |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2689 void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2690 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
|
2691 { |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2692 ::reset_default_properties (default_properties); |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2693 } |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2694 |
6406 | 2695 // --------------------------------------------------------------------- |
2696 | |
7363 | 2697 void |
2698 figure::properties::set_currentaxes (const octave_value& v) | |
2699 { | |
7378 | 2700 graphics_handle val (v); |
6705 | 2701 |
6874 | 2702 if (error_state) |
2703 return; | |
2704 | |
7070 | 2705 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2706 currentaxes = val; |
2707 else | |
2708 gripe_set_invalid ("currentaxes"); | |
2709 } | |
2710 | |
2711 void | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2712 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
|
2713 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2714 base_properties::remove_child (gh); |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2715 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2716 if (gh == currentaxes.handle_value ()) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2717 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2718 graphics_handle new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2719 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2720 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
|
2721 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2722 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
|
2723 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2724 graphics_handle kid = kids(i); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2725 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2726 graphics_object go = gh_manager::get_object (kid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2727 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2728 if (go.isa ("axes")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2729 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2730 new_currentaxes = kid; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2731 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2732 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2733 } |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2734 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2735 currentaxes = new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2736 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2737 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2738 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2739 void |
6874 | 2740 figure::properties::set_visible (const octave_value& val) |
2741 { | |
2742 std::string s = val.string_value (); | |
2743 | |
2744 if (! error_state) | |
2745 { | |
2746 if (s == "on") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2747 xset (0, "currentfigure", __myhandle__.value ()); |
6874 | 2748 |
2749 visible = val; | |
2750 } | |
2751 } | |
2752 | |
7445 | 2753 Matrix |
7447 | 2754 figure::properties::get_boundingbox (bool) const |
7445 | 2755 { |
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
|
2756 Matrix screen_size = screen_size_pixels (); |
7445 | 2757 Matrix pos; |
2758 | |
10949
848f3a13b7cf
Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents:
10948
diff
changeset
|
2759 pos = convert_position (get_position ().matrix_value (), get_units (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2760 "pixels", screen_size); |
7445 | 2761 |
2762 pos(0)--; | |
2763 pos(1)--; | |
7447 | 2764 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 2765 |
2766 return pos; | |
2767 } | |
2768 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2769 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2770 figure::properties::set_boundingbox (const Matrix& bb) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2771 { |
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
|
2772 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
|
2773 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
|
2774 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2775 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
|
2776 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
|
2777 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
|
2778 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
|
2779 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2780 set_position (pos); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2781 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2782 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2783 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2784 figure::properties::set_position (const octave_value& v) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2785 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2786 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
|
2787 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2788 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
|
2789 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2790 old_bb = get_boundingbox (); |
10949
848f3a13b7cf
Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents:
10948
diff
changeset
|
2791 position = v; |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2792 new_bb = get_boundingbox (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2793 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2794 if (old_bb != new_bb) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2795 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2796 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
|
2797 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2798 execute_resizefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2799 update_boundingbox (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2800 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2801 } |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2802 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2803 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
|
2804 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2805 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2806 |
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
|
2807 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
|
2808 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
|
2809 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2810 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
|
2811 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2812 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
|
2813 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
|
2814 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
|
2815 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
2816 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
|
2817 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
|
2818 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
|
2819 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2820 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
|
2821 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
|
2822 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2823 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
|
2824 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
|
2825 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2826 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2827 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2828 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2829 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2830 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2831 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
|
2832 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
|
2833 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2834 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
|
2835 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2836 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
|
2837 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
|
2838 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
|
2839 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
2840 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
|
2841 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
|
2842 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
|
2843 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2844 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
|
2845 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2846 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
|
2847 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
|
2848 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2849 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2850 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2851 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2852 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2853 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2854 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
|
2855 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
|
2856 { |
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
|
2857 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
|
2858 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2859 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
|
2860 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2861 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
|
2862 double mm2units; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2863 |
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
|
2864 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
|
2865 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2866 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
|
2867 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
|
2868 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2869 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
|
2870 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2871 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
|
2872 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
|
2873 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2874 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
|
2875 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2876 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
|
2877 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
|
2878 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2879 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2880 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
|
2881 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2882 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
|
2883 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
|
2884 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2885 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
|
2886 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2887 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
|
2888 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
|
2889 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2890 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
|
2891 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2892 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
|
2893 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
|
2894 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2895 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
|
2896 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2897 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
|
2898 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
|
2899 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2900 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
|
2901 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2902 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
|
2903 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
|
2904 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2905 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
|
2906 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2907 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
|
2908 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
|
2909 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2910 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
|
2911 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2912 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
|
2913 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
|
2914 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2915 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
|
2916 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2917 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
|
2918 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
|
2919 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2920 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
|
2921 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2922 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
|
2923 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
|
2924 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2925 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
|
2926 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2927 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
|
2928 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
|
2929 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2930 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
|
2931 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2932 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
|
2933 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
|
2934 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2935 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
|
2936 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2937 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
|
2938 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
|
2939 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2940 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
|
2941 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2942 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
|
2943 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
|
2944 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2945 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
|
2946 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2947 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
|
2948 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
|
2949 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2950 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
|
2951 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2952 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
|
2953 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
|
2954 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2955 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
|
2956 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2957 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
|
2958 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
|
2959 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2960 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
|
2961 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2962 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
|
2963 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
|
2964 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2965 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
|
2966 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2967 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
|
2968 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
|
2969 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2970 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
|
2971 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2972 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
|
2973 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
|
2974 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2975 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
|
2976 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2977 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
|
2978 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
|
2979 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2980 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
|
2981 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2982 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
|
2983 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
|
2984 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2985 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
|
2986 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2987 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
|
2988 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
|
2989 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2990 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
|
2991 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2992 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
|
2993 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
|
2994 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2995 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
|
2996 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2997 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
|
2998 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
|
2999 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3000 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
|
3001 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3002 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
|
3003 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
|
3004 } |
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 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3006 |
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
|
3007 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
|
3008 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3009 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3010 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
|
3011 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
|
3012 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3013 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
|
3014 Matrix sz = get_papersize ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3015 |
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
|
3016 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
|
3017 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
|
3018 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
|
3019 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
|
3020 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3021 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
|
3022 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
|
3023 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3024 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
|
3025 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3026 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
|
3027 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3028 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
|
3029 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
|
3030 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3031 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
|
3032 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3033 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
|
3034 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
|
3035 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3036 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3037 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
|
3038 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3039 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
|
3040 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
|
3041 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3042 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
|
3043 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3044 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
|
3045 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
|
3046 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3047 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3048 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
|
3049 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
|
3050 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3051 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
|
3052 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
|
3053 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
|
3054 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
|
3055 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3056 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
|
3057 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
|
3058 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3059 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3060 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
|
3061 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
|
3062 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3063 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
|
3064 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3065 if (! typ.compare ("<custom>")) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3066 // 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
|
3067 // 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
|
3068 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
|
3069 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3070 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3071 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
|
3072 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
|
3073 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3074 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
|
3075 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3076 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3077 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
|
3078 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
|
3079 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3080 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
|
3081 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3082 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
|
3083 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
|
3084 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3085 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
|
3086 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
|
3087 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3088 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3089 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3090 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3091 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
|
3092 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
|
3093 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3094 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
|
3095 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
|
3096 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3097 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3098 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3099 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3100 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3101 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3102 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3103 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
3104 std::string nm = get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3105 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3106 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
|
3107 if (! nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3108 os << ": " << get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3109 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3110 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3111 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3112 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3113 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3114 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3115 |
6836 | 3116 octave_value |
7189 | 3117 figure::get_default (const caseless_str& name) const |
6836 | 3118 { |
3119 octave_value retval = default_properties.lookup (name); | |
3120 | |
3121 if (retval.is_undefined ()) | |
3122 { | |
3123 graphics_handle parent = get_parent (); | |
3124 graphics_object parent_obj = gh_manager::get_object (parent); | |
3125 | |
3126 retval = parent_obj.get_default (name); | |
3127 } | |
3128 | |
3129 return retval; | |
3130 } | |
3131 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3132 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3133 figure::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3134 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3135 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3136 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3137 |
6406 | 3138 // --------------------------------------------------------------------- |
3139 | |
8249 | 3140 void |
3141 axes::properties::init (void) | |
3142 { | |
3143 position.add_constraint (dim_vector (1, 4)); | |
3144 position.add_constraint (dim_vector (0, 0)); | |
3145 outerposition.add_constraint (dim_vector (1, 4)); | |
3146 colororder.add_constraint (dim_vector (-1, 3)); | |
3147 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
3148 plotboxaspectratio.add_constraint (dim_vector (1, 3)); | |
3149 xlim.add_constraint (2); | |
3150 ylim.add_constraint (2); | |
3151 zlim.add_constraint (2); | |
3152 clim.add_constraint (2); | |
3153 alim.add_constraint (2); | |
3154 xtick.add_constraint (dim_vector (1, -1)); | |
3155 ytick.add_constraint (dim_vector (1, -1)); | |
3156 ztick.add_constraint (dim_vector (1, -1)); | |
3157 Matrix vw (1, 2, 0); | |
3158 vw(1) = 90; | |
3159 view = vw; | |
3160 view.add_constraint (dim_vector (1, 2)); | |
3161 cameraposition.add_constraint (dim_vector (1, 3)); | |
3162 Matrix upv (1, 3, 0.0); | |
3163 upv(2) = 1.0; | |
3164 cameraupvector = upv; | |
3165 cameraupvector.add_constraint (dim_vector (1, 3)); | |
3166 currentpoint.add_constraint (dim_vector (2, 3)); | |
3167 ticklength.add_constraint (dim_vector (1, 2)); | |
3168 tightinset.add_constraint (dim_vector (1, 4)); | |
3169 | |
3170 x_zlim.resize (1, 2); | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3171 |
8249 | 3172 sx = "linear"; |
3173 sy = "linear"; | |
3174 sz = "linear"; | |
3175 | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3176 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3177 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3178 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3179 |
8249 | 3180 xset (xlabel.handle_value (), "handlevisibility", "off"); |
3181 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3182 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3183 xset (title.handle_value (), "handlevisibility", "off"); | |
3184 | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3185 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
|
3186 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3187 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
|
3188 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3189 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
|
3190 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3191 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
|
3192 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3193 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3194 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
|
3195 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3196 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
|
3197 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3198 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
|
3199 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3200 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3201 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
|
3202 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
|
3203 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3204 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3205 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3206 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3207 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3208 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3209 xset (title.handle_value (), "clipping", "off"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3210 |
8249 | 3211 adopt (xlabel.handle_value ()); |
3212 adopt (ylabel.handle_value ()); | |
3213 adopt (zlabel.handle_value ()); | |
3214 adopt (title.handle_value ()); | |
3215 } | |
3216 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3217 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
|
3218 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
|
3219 { |
8208 | 3220 #if 0 |
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
|
3221 // FIXME -- this should take font metrics into consideration, |
8208 | 3222 // and also the fact that the colorbox leaves the outerposition |
3223 // alone but alters the position. For now just don't adjust the | |
3224 // positions relative to each other. | |
3225 | |
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
|
3226 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
|
3227 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3228 Matrix outpos = outerposition.get ().matrix_value (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3229 Matrix defpos = default_axes_position (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3230 Matrix pos(outpos); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3231 pos(0) = outpos(0) + defpos(0) * outpos(2); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3232 pos(1) = outpos(1) + defpos(1) * outpos(3); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3233 pos(2) = outpos(2) * defpos(2); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3234 pos(3) = outpos(3) * defpos(3); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3235 position = pos; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3236 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3237 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
|
3238 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3239 Matrix pos = position.get ().matrix_value (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3240 pos(0) -= pos(2)*0.05; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3241 pos(1) -= pos(3)*0.05; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3242 pos(2) *= 1.1; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3243 pos(3) *= 1.1; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3244 outerposition = pos; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3245 } |
8208 | 3246 #endif |
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
|
3247 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3248 update_transform (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3249 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3250 |
7363 | 3251 void |
8249 | 3252 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
|
3253 const std::string& who, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3254 const octave_value& v) |
6962 | 3255 { |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3256 graphics_handle val; |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3257 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3258 if (v.is_string ()) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3259 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3260 val = gh_manager::make_graphics_handle ("text", __myhandle__, false); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3261 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3262 xset (val, "string", v); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3263 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3264 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3265 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3266 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
|
3267 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3268 if (go.isa ("text")) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3269 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
|
3270 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3271 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3272 std::string cname = v.class_name (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3273 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3274 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
|
3275 who.c_str (), cname.c_str ()); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3276 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3277 } |
6962 | 3278 |
6874 | 3279 if (! error_state) |
3280 { | |
8249 | 3281 xset (val, "handlevisibility", "off"); |
3282 | |
3283 gh_manager::free (hp.handle_value ()); | |
3284 | |
3285 base_properties::remove_child (hp.handle_value ()); | |
3286 | |
3287 hp = val; | |
3288 | |
3289 adopt (hp.handle_value ()); | |
6874 | 3290 } |
3291 } | |
3292 | |
3293 void | |
7363 | 3294 axes::properties::set_xlabel (const octave_value& v) |
6874 | 3295 { |
8249 | 3296 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
|
3297 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
|
3298 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
|
3299 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
|
3300 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
|
3301 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
|
3302 xset (xlabel.handle_value (), "color", get_xcolor ()); |
6874 | 3303 } |
3304 | |
3305 void | |
7363 | 3306 axes::properties::set_ylabel (const octave_value& v) |
6874 | 3307 { |
8249 | 3308 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
|
3309 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
|
3310 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
|
3311 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
|
3312 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
|
3313 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
|
3314 xset (ylabel.handle_value (), "color", get_ycolor ()); |
6874 | 3315 } |
3316 | |
3317 void | |
7363 | 3318 axes::properties::set_zlabel (const octave_value& v) |
6874 | 3319 { |
8249 | 3320 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
|
3321 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
|
3322 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
|
3323 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
|
3324 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
|
3325 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
|
3326 xset (zlabel.handle_value (), "color", get_zcolor ()); |
8249 | 3327 } |
3328 | |
3329 void | |
3330 axes::properties::set_title (const octave_value& v) | |
3331 { | |
3332 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
|
3333 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
|
3334 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
|
3335 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
|
3336 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
|
3337 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
|
3338 xset (title.handle_value (), "clipping", "off"); |
6874 | 3339 } |
3340 | |
3341 void | |
6844 | 3342 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
|
3343 const std::string& mode) |
6705 | 3344 { |
3345 box = "on"; | |
6962 | 3346 colororder = default_colororder (); |
6705 | 3347 dataaspectratio = Matrix (1, 3, 1.0); |
3348 dataaspectratiomode = "auto"; | |
7363 | 3349 layer = "bottom"; |
6705 | 3350 |
3351 Matrix tlim (1, 2, 0.0); | |
3352 tlim(1) = 1; | |
3353 xlim = tlim; | |
3354 ylim = tlim; | |
3355 zlim = tlim; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3356 |
6807 | 3357 Matrix cl (1, 2, 0); |
3358 cl(1) = 1; | |
3359 clim = cl; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3360 |
7363 | 3361 xlimmode = "auto"; |
3362 ylimmode = "auto"; | |
3363 zlimmode = "auto"; | |
3364 climmode = "auto"; | |
8208 | 3365 |
6705 | 3366 xgrid = "off"; |
3367 ygrid = "off"; | |
3368 zgrid = "off"; | |
3369 xminorgrid = "off"; | |
3370 yminorgrid = "off"; | |
3371 zminorgrid = "off"; | |
3372 xtick = Matrix (); | |
3373 ytick = Matrix (); | |
3374 ztick = Matrix (); | |
3375 xtickmode = "auto"; | |
3376 ytickmode = "auto"; | |
3377 ztickmode = "auto"; | |
3378 xticklabel = ""; | |
3379 yticklabel = ""; | |
3380 zticklabel = ""; | |
3381 xticklabelmode = "auto"; | |
3382 yticklabelmode = "auto"; | |
3383 zticklabelmode = "auto"; | |
10565
2880a862b1a8
Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents:
10553
diff
changeset
|
3384 color = "none"; |
7364 | 3385 xcolor = color_values ("black"); |
3386 ycolor = color_values ("black"); | |
3387 zcolor = color_values ("black"); | |
7363 | 3388 xscale = "linear"; |
3389 yscale = "linear"; | |
3390 zscale = "linear"; | |
6705 | 3391 xdir = "normal"; |
3392 ydir = "normal"; | |
3393 zdir = "normal"; | |
7363 | 3394 yaxislocation = "left"; |
3395 xaxislocation = "bottom"; | |
6705 | 3396 |
7427 | 3397 // Note: camera properties will be set through update_transform |
3398 camerapositionmode = "auto"; | |
3399 cameratargetmode = "auto"; | |
3400 cameraupvectormode = "auto"; | |
3401 cameraviewanglemode = "auto"; | |
3402 plotboxaspectratio = Matrix (1, 3, 1.0); | |
3403 drawmode = "normal"; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
3404 gridlinestyle = ":"; |
7427 | 3405 linestyleorder = "-"; |
3406 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
3407 minorgridlinestyle = ":"; |
7427 | 3408 // Note: plotboxaspectratio will be set through update_aspectratiors |
3409 plotboxaspectratiomode = "auto"; | |
3410 projection = "orthographic"; | |
3411 tickdir = "in"; | |
3412 tickdirmode = "auto"; | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
3413 ticklength = default_axes_ticklength (); |
7427 | 3414 tightinset = Matrix (1, 4, 0.0); |
3415 | |
3416 sx = "linear"; | |
3417 sy = "linear"; | |
3418 sz = "linear"; | |
3419 | |
6705 | 3420 Matrix tview (1, 2, 0.0); |
3421 tview(1) = 90; | |
3422 view = tview; | |
3423 | |
6765 | 3424 visible = "on"; |
6705 | 3425 nextplot = "replace"; |
3426 | |
3427 if (mode != "replace") | |
3428 { | |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3429 fontangle = "normal"; |
8944
cb0e9facc342
make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
3430 fontname = OCTAVE_DEFAULT_FONTNAME; |
11384
1511bbfe6a6e
Change axes default fontsize from 12 to 10.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11283
diff
changeset
|
3431 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
|
3432 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
|
3433 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
|
3434 |
6406 | 3435 Matrix touterposition (1, 4, 0.0); |
3436 touterposition(2) = 1; | |
3437 touterposition(3) = 1; | |
3438 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
|
3439 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3440 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
|
3441 |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3442 activepositionproperty = "outerposition"; |
6406 | 3443 } |
3444 | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3445 delete_children (true); |
6432 | 3446 |
8249 | 3447 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); |
3448 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3449 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3450 title = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3451 | |
3452 xset (xlabel.handle_value (), "handlevisibility", "off"); | |
3453 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3454 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3455 xset (title.handle_value (), "handlevisibility", "off"); | |
3456 | |
8636 | 3457 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
|
3458 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 3459 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
|
3460 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 3461 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
|
3462 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 3463 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
|
3464 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 3465 |
3466 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
|
3467 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 3468 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
|
3469 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 3470 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
|
3471 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 3472 |
3473 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
|
3474 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
|
3475 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3476 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3477 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3478 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3479 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3480 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3481 xset (title.handle_value (), "clipping", "off"); |
8636 | 3482 |
8249 | 3483 adopt (xlabel.handle_value ()); |
3484 adopt (ylabel.handle_value ()); | |
3485 adopt (zlabel.handle_value ()); | |
3486 adopt (title.handle_value ()); | |
3487 | |
7427 | 3488 update_transform (); |
3489 | |
6705 | 3490 override_defaults (obj); |
3491 } | |
3492 | |
8208 | 3493 void |
3494 axes::properties::delete_text_child (handle_property& hp) | |
6874 | 3495 { |
8208 | 3496 graphics_handle h = hp.handle_value (); |
3497 | |
3498 if (h.ok ()) | |
3499 { | |
3500 graphics_object go = gh_manager::get_object (h); | |
3501 | |
3502 if (go.valid_object ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3503 gh_manager::free (h); |
8249 | 3504 |
3505 base_properties::remove_child (h); | |
8208 | 3506 } |
3507 | |
8249 | 3508 // FIXME -- is it necessary to check whether the axes object is |
3509 // being deleted now? I think this function is only called when an | |
3510 // individual child object is delete and not when the parent axes | |
3511 // object is deleted. | |
3512 | |
8208 | 3513 if (! is_beingdeleted ()) |
8249 | 3514 { |
3515 hp = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3516 | |
3517 xset (hp.handle_value (), "handlevisibility", "off"); | |
3518 | |
3519 adopt (hp.handle_value ()); | |
3520 } | |
6705 | 3521 } |
6406 | 3522 |
6705 | 3523 void |
6844 | 3524 axes::properties::remove_child (const graphics_handle& h) |
6705 | 3525 { |
8249 | 3526 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
8208 | 3527 delete_text_child (xlabel); |
7363 | 3528 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
8208 | 3529 delete_text_child (ylabel); |
7363 | 3530 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
8208 | 3531 delete_text_child (zlabel); |
8249 | 3532 else if (title.handle_value ().ok () && h == title.handle_value ()) |
3533 delete_text_child (title); | |
6705 | 3534 else |
3535 base_properties::remove_child (h); | |
3536 } | |
6406 | 3537 |
7427 | 3538 inline Matrix |
3539 xform_matrix (void) | |
3540 { | |
3541 Matrix m (4, 4, 0.0); | |
3542 for (int i = 0; i < 4; i++) | |
3543 m(i,i) = 1; | |
3544 return m; | |
3545 } | |
3546 | |
3547 inline ColumnVector | |
3548 xform_vector (void) | |
3549 { | |
3550 ColumnVector v (4, 0.0); | |
3551 v(3) = 1; | |
3552 return v; | |
3553 } | |
3554 | |
3555 inline ColumnVector | |
3556 xform_vector (double x, double y, double z) | |
3557 { | |
3558 ColumnVector v (4, 1.0); | |
3559 v(0) = x; v(1) = y; v(2) = z; | |
3560 return v; | |
3561 } | |
3562 | |
3563 inline ColumnVector | |
3564 transform (const Matrix& m, double x, double y, double z) | |
3565 { | |
3566 return (m * xform_vector (x, y, z)); | |
3567 } | |
3568 | |
3569 inline Matrix | |
3570 xform_scale (double x, double y, double z) | |
3571 { | |
3572 Matrix m (4, 4, 0.0); | |
3573 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
3574 return m; | |
3575 } | |
3576 | |
3577 inline Matrix | |
3578 xform_translate (double x, double y, double z) | |
3579 { | |
3580 Matrix m = xform_matrix (); | |
3581 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
3582 return m; | |
3583 } | |
3584 | |
3585 inline void | |
3586 scale (Matrix& m, double x, double y, double z) | |
3587 { | |
3588 m = m * xform_scale (x, y, z); | |
3589 } | |
3590 | |
3591 inline void | |
3592 translate (Matrix& m, double x, double y, double z) | |
3593 { | |
3594 m = m * xform_translate (x, y, z); | |
3595 } | |
3596 | |
3597 inline void | |
3598 xform (ColumnVector& v, const Matrix& m) | |
3599 { | |
3600 v = m*v; | |
3601 } | |
3602 | |
3603 inline void | |
3604 scale (ColumnVector& v, double x, double y, double z) | |
3605 { | |
3606 v(0) *= x; | |
3607 v(1) *= y; | |
3608 v(2) *= z; | |
3609 } | |
3610 | |
3611 inline void | |
3612 translate (ColumnVector& v, double x, double y, double z) | |
3613 { | |
3614 v(0) += x; | |
3615 v(1) += y; | |
3616 v(2) += z; | |
3617 } | |
3618 | |
3619 inline void | |
3620 normalize (ColumnVector& v) | |
3621 { | |
3622 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); | |
3623 scale (v, fact, fact, fact); | |
3624 } | |
3625 | |
3626 inline double | |
3627 dot (const ColumnVector& v1, const ColumnVector& v2) | |
3628 { | |
3629 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
3630 } | |
3631 | |
3632 inline double | |
3633 norm (const ColumnVector& v) | |
3634 { | |
3635 return sqrt (dot (v, v)); | |
3636 } | |
3637 | |
3638 inline ColumnVector | |
3639 cross (const ColumnVector& v1, const ColumnVector& v2) | |
3640 { | |
3641 ColumnVector r = xform_vector (); | |
3642 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
3643 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
3644 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
3645 return r; | |
3646 } | |
3647 | |
3648 inline Matrix | |
3649 unit_cube (void) | |
3650 { | |
3651 static double data[32] = { | |
3652 0,0,0,1, | |
3653 1,0,0,1, | |
3654 0,1,0,1, | |
3655 0,0,1,1, | |
3656 1,1,0,1, | |
3657 1,0,1,1, | |
3658 0,1,1,1, | |
3659 1,1,1,1}; | |
3660 Matrix m (4, 8); | |
3661 memcpy (m.fortran_vec (), data, sizeof(double)*32); | |
3662 return m; | |
3663 } | |
3664 | |
3665 inline ColumnVector | |
3666 cam2xform (const Array<double>& m) | |
3667 { | |
3668 ColumnVector retval (4, 1.0); | |
3669 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); | |
3670 return retval; | |
3671 } | |
3672 | |
3673 inline RowVector | |
3674 xform2cam (const ColumnVector& v) | |
3675 { | |
3676 return v.extract_n (0, 3).transpose (); | |
3677 } | |
3678 | |
3679 void | |
3680 axes::properties::update_camera (void) | |
3681 { | |
3682 double xd = (xdir_is ("normal") ? 1 : -1); | |
3683 double yd = (ydir_is ("normal") ? 1 : -1); | |
3684 double zd = (zdir_is ("normal") ? 1 : -1); | |
3685 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3686 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
|
3687 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
|
3688 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
|
3689 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3690 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
|
3691 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
|
3692 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
|
3693 |
7427 | 3694 Matrix pb = get_plotboxaspectratio ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3695 |
7427 | 3696 bool autocam = (camerapositionmode_is ("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3697 && cameratargetmode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3698 && cameraupvectormode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3699 && cameraviewanglemode_is ("auto")); |
7427 | 3700 bool dowarp = (autocam && dataaspectratiomode_is("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3701 && plotboxaspectratiomode_is ("auto")); |
7427 | 3702 |
3703 ColumnVector c_eye (xform_vector ()); | |
3704 ColumnVector c_center (xform_vector ()); | |
3705 ColumnVector c_upv (xform_vector ()); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3706 |
7427 | 3707 if (cameratargetmode_is ("auto")) |
3708 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3709 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
|
3710 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
|
3711 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 3712 |
3713 cameratarget = xform2cam (c_center); | |
3714 } | |
3715 else | |
3716 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
|
3717 |
7427 | 3718 if (camerapositionmode_is ("auto")) |
3719 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3720 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
|
3721 double az = tview(0), el = tview(1); |
7427 | 3722 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
3723 | |
3724 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3725 c_eye(2) = d*signum(el); |
7427 | 3726 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3727 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3728 az *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3729 el *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3730 c_eye(0) = d*cos(el)*sin(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3731 c_eye(1) = -d*cos(el)*cos(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3732 c_eye(2) = d*sin(el); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3733 } |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3734 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
|
3735 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
|
3736 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 3737 |
3738 cameraposition = xform2cam (c_eye); | |
3739 } | |
3740 else | |
3741 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
3742 | |
3743 if (cameraupvectormode_is ("auto")) | |
3744 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3745 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
|
3746 double az = tview(0), el = tview(1); |
7427 | 3747 |
3748 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3749 { |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3750 c_upv(0) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3751 -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
|
3752 c_upv(1) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3753 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
|
3754 } |
7427 | 3755 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3756 c_upv(2) = 1; |
7427 | 3757 |
3758 cameraupvector = xform2cam (c_upv); | |
3759 } | |
3760 else | |
3761 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
3762 | |
3763 Matrix x_view = xform_matrix (); | |
3764 Matrix x_projection = xform_matrix (); | |
3765 Matrix x_viewport = xform_matrix (); | |
3766 Matrix x_normrender = xform_matrix (); | |
3767 Matrix x_pre = xform_matrix (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3768 |
7427 | 3769 x_render = xform_matrix (); |
3770 x_render_inv = xform_matrix (); | |
3771 | |
3772 scale (x_pre, pb(0), pb(1), pb(2)); | |
3773 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
|
3774 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
|
3775 zd/(zlimits(1)-zlimits(0))); |
7427 | 3776 translate (x_pre, -xo, -yo, -zo); |
3777 | |
3778 xform (c_eye, x_pre); | |
3779 xform (c_center, x_pre); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3780 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
|
3781 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 3782 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
3783 | |
3784 ColumnVector F (c_center), f (F), UP (c_upv); | |
3785 normalize (f); | |
3786 normalize (UP); | |
3787 | |
7440 | 3788 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 3789 { |
3790 double fa = 1/sqrt(1-f(2)*f(2)); | |
3791 scale (UP, fa, fa, fa); | |
3792 } | |
3793 | |
3794 ColumnVector s = cross (f, UP); | |
3795 ColumnVector u = cross (s, f); | |
3796 | |
3797 scale (x_view, 1, 1, -1); | |
3798 Matrix l = xform_matrix (); | |
3799 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
3800 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
3801 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
3802 x_view = x_view * l; | |
3803 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
3804 scale (x_view, pb(0), pb(1), pb(2)); | |
3805 translate (x_view, -0.5, -0.5, -0.5); | |
3806 | |
3807 Matrix x_cube = x_view * unit_cube (); | |
3808 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max (); | |
3809 double xM = cmax(0)-cmin(0); | |
3810 double yM = cmax(1)-cmin(1); | |
3811 | |
7447 | 3812 Matrix bb = get_boundingbox (true); |
7427 | 3813 |
3814 double v_angle; | |
3815 | |
3816 if (cameraviewanglemode_is ("auto")) | |
3817 { | |
3818 double af; | |
3819 | |
8333 | 3820 // FIXME -- was this really needed? When compared to Matlab, it |
7427 | 3821 // 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
|
3822 // graphics toolkit to see results visually. |
7427 | 3823 if (false && dowarp) |
3824 af = 1.0 / (xM > yM ? xM : yM); | |
3825 else | |
3826 { | |
3827 if ((bb(2)/bb(3)) > (xM/yM)) | |
3828 af = 1.0 / yM; | |
3829 else | |
3830 af = 1.0 / xM; | |
3831 } | |
3832 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
3833 | |
3834 cameraviewangle = v_angle; | |
3835 } | |
3836 else | |
3837 v_angle = get_cameraviewangle (); | |
3838 | |
3839 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
3840 scale (x_projection, pf, pf, 1); | |
3841 | |
3842 if (dowarp) | |
3843 { | |
3844 xM *= pf; | |
3845 yM *= pf; | |
7447 | 3846 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 3847 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
3848 } | |
3849 else | |
3850 { | |
3851 double pix = 1; | |
3852 if (autocam) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3853 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3854 if ((bb(2)/bb(3)) > (xM/yM)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3855 pix = bb(3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3856 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3857 pix = bb(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3858 } |
7427 | 3859 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3860 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); |
7447 | 3861 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 3862 scale (x_viewport, pix, -pix, 1); |
3863 } | |
3864 | |
3865 x_normrender = x_viewport * x_projection * x_view; | |
3866 | |
3867 x_cube = x_normrender * unit_cube (); | |
3868 cmin = x_cube.row_min (); | |
3869 cmax = x_cube.row_max (); | |
3870 x_zlim.resize (1, 2); | |
3871 x_zlim(0) = cmin(2); | |
3872 x_zlim(1) = cmax(2); | |
3873 | |
3874 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
|
3875 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
|
3876 zd/(zlimits(1)-zlimits(0))); |
7427 | 3877 translate (x_render, -xo, -yo, -zo); |
3878 | |
3879 x_viewtransform = x_view; | |
3880 x_projectiontransform = x_projection; | |
3881 x_viewporttransform = x_viewport; | |
3882 x_normrendertransform = x_normrender; | |
3883 x_rendertransform = x_render; | |
3884 | |
3885 x_render_inv = x_render.inverse (); | |
3886 | |
3887 // Note: these matrices are a slight modified version of the regular | |
3888 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
3889 // => x_gl_mat2) | |
3890 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
|
3891 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
|
3892 zd/(zlimits(1)-zlimits(0))); |
7427 | 3893 translate (x_gl_mat1, -xo, -yo, -zo); |
3894 x_gl_mat2 = x_viewport * x_projection; | |
3895 } | |
3896 | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3897 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3898 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3899 double xlength, double ylength, double zlength) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3900 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3901 double xval = xlength/scalefactors(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3902 double yval = ylength/scalefactors(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3903 double zval = zlength/scalefactors(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3904 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3905 double minval = xmin (xmin (xval, yval), zval); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3906 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3907 aspectratios(0) = xval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3908 aspectratios(1) = yval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3909 aspectratios(2) = zval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3910 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3911 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3912 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3913 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
|
3914 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
|
3915 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3916 if (tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3917 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3918 double minval = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3919 double maxval = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3920 double min_pos = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3921 get_children_limits (minval, maxval, min_pos, kids, limit_type); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3922 if (!xisinf (minval) && !xisnan (minval) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3923 && !xisinf (maxval) && !xisnan (maxval)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3924 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3925 limits(0) = minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3926 limits(1) = maxval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3927 s = xmax(s, (maxval - minval) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3928 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3929 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3930 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3931 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
|
3932 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3933 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3934 static bool updating_aspectratios = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3935 |
7427 | 3936 void |
3937 axes::properties::update_aspectratios (void) | |
3938 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3939 if (updating_aspectratios) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3940 return; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3941 |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3942 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
|
3943 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
|
3944 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
|
3945 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3946 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
|
3947 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
|
3948 double dz = (zlimits(1)-zlimits(0)); |
7427 | 3949 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3950 Matrix da = get_dataaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3951 Matrix pba = get_plotboxaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3952 |
7427 | 3953 if (dataaspectratiomode_is ("auto")) |
3954 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3955 if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3956 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3957 pba = Matrix (1, 3, 1.0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3958 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3959 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3960 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3961 normalized_aspectratios (da, pba, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3962 dataaspectratio.set (da, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3963 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3964 else if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3965 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3966 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3967 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3968 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3969 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3970 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3971 double s = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3972 bool modified_limits = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3973 Matrix kids; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3974 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3975 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
|
3976 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3977 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3978 kids = get_children (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3979 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
|
3980 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
|
3981 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
|
3982 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3983 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
|
3984 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3985 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3986 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
|
3987 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3988 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
|
3989 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3990 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3991 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
|
3992 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3993 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
|
3994 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3995 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3996 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
|
3997 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3998 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3999 if (modified_limits) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4000 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4001 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4002 unwind_protect frame; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4003 frame.protect_var (updating_aspectratios); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4004 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4005 updating_aspectratios = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4006 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4007 dx = pba(0) *da(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4008 dy = pba(1) *da(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4009 dz = pba(2) *da(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4010 if (xisinf (s)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4011 s = 1 / xmin (xmin (dx, dy), dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4012 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4013 if (xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4014 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4015 dx = s * dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4016 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
|
4017 xlimits(1) = xlimits(0) + dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4018 set_xlim (xlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4019 set_xlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4020 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4021 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4022 if (ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4023 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4024 dy = s * dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4025 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
|
4026 ylimits(1) = ylimits(0) + dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4027 set_ylim (ylimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4028 set_ylimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4029 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4030 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4031 if (zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4032 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4033 dz = s * dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4034 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
|
4035 zlimits(1) = zlimits(0) + dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4036 set_zlim (zlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4037 set_zlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4038 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4039 } |
7427 | 4040 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4041 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4042 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4043 plotboxaspectratio.set (pba, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4044 } |
7427 | 4045 } |
4046 } | |
4047 | |
7447 | 4048 // The INTERNAL flag defines whether position or outerposition is used. |
4049 | |
7427 | 4050 Matrix |
7447 | 4051 axes::properties::get_boundingbox (bool internal) const |
7427 | 4052 { |
7447 | 4053 graphics_object obj = gh_manager::get_object (get_parent ()); |
4054 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); | |
4055 Matrix pos = (internal ? | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4056 get_position ().matrix_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4057 : get_outerposition ().matrix_value ()); |
7447 | 4058 |
4059 | |
4060 pos = convert_position (pos, get_units (), "pixels", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4061 parent_bb.extract_n (0, 2, 1, 2)); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4062 |
7427 | 4063 pos(0)--; |
4064 pos(1)--; | |
7447 | 4065 pos(1) = parent_bb(3) - pos(1) - pos(3); |
7427 | 4066 |
4067 return pos; | |
4068 } | |
4069 | |
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
|
4070 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
|
4071 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
|
4072 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4073 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
|
4074 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4075 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
|
4076 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
|
4077 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4078 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
|
4079 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
|
4080 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4081 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4082 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4083 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4084 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
|
4085 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
|
4086 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4087 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
|
4088 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
|
4089 caseless_str new_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
|
4090 set_position (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4091 set_outerposition (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4092 set_tightinset (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4093 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4094 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4095 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
|
4096 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
|
4097 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4098 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
|
4099 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4100 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
|
4101 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
|
4102 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4103 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
|
4104 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
|
4105 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4106 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4107 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4108 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4109 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
|
4110 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
|
4111 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4112 caseless_str new_units = 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
|
4113 double fsz = get_fontsize (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4114 double pixelsperinch = xget (0, "screenpixelsperinch").double_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
|
4115 double parent_height = get_boundingbox (true).elem (3); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4116 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4117 if (old_units.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
|
4118 fsz = fsz * parent_height * 72 / pixelsperinch; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4119 else if (old_units.compare ("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
|
4120 fsz = fsz * 72 / pixelsperinch; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4121 else if (old_units.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
|
4122 fsz = fsz * 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4123 else if (old_units.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
|
4124 fsz = fsz * 72 / 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
|
4125 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4126 if (new_units.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
|
4127 fsz = fsz * pixelsperinch / parent_height / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4128 else if (new_units.compare ("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
|
4129 fsz = fsz * pixelsperinch / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4130 else if (new_units.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
|
4131 fsz = fsz / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4132 else if (new_units.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
|
4133 fsz = fsz * 2.54 / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4134 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4135 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
|
4136 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4137 |
7435 | 4138 ColumnVector |
4139 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 4140 { |
4141 return ::xform_vector (x, y, z); | |
4142 } | |
7435 | 4143 |
4144 Matrix | |
4145 graphics_xform::xform_eye (void) | |
7869 | 4146 { |
4147 return ::xform_matrix (); | |
4148 } | |
7435 | 4149 |
4150 ColumnVector | |
4151 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
|
4152 bool use_scale) const |
7435 | 4153 { |
4154 if (use_scale) | |
4155 { | |
4156 x = sx.scale (x); | |
4157 y = sy.scale (y); | |
4158 z = sz.scale (z); | |
4159 } | |
4160 | |
4161 return ::transform (xform, x, y, z); | |
4162 } | |
4163 | |
4164 ColumnVector | |
4165 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
|
4166 bool use_scale) const |
7435 | 4167 { |
4168 ColumnVector v = ::transform (xform_inv, x, y, z); | |
4169 | |
4170 if (use_scale) | |
4171 { | |
4172 v(0) = sx.unscale (v(0)); | |
4173 v(1) = sy.unscale (v(1)); | |
4174 v(2) = sz.unscale (v(2)); | |
4175 } | |
4176 | |
4177 return v; | |
4178 } | |
4179 | |
6836 | 4180 octave_value |
7189 | 4181 axes::get_default (const caseless_str& name) const |
6836 | 4182 { |
4183 octave_value retval = default_properties.lookup (name); | |
4184 | |
4185 if (retval.is_undefined ()) | |
4186 { | |
4187 graphics_handle parent = get_parent (); | |
4188 graphics_object parent_obj = gh_manager::get_object (parent); | |
4189 | |
4190 retval = parent_obj.get_default (name); | |
4191 } | |
4192 | |
4193 return retval; | |
4194 } | |
4195 | |
8333 | 4196 // FIXME -- remove. |
4197 // 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
|
4198 /* |
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
|
4199 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
|
4200 check_limit_vals (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4201 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
|
4202 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4203 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
|
4204 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
|
4205 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
|
4206 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
|
4207 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
|
4208 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
|
4209 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
|
4210 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
|
4211 min_pos = 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
|
4212 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4213 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4214 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4215 static void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4216 check_limit_vals (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4217 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
|
4218 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4219 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
|
4220 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4221 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
|
4222 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4223 if (! error_state && m.numel () == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4224 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4225 double val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4226 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4227 val = m(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4228 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4229 min_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4230 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4231 val = m(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4232 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4233 max_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4234 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4235 val = m(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4236 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
|
4237 min_pos = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4238 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4239 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4240 } |
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
|
4241 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4242 // magform(x) Returns (a, b), where x = a * 10^b, a >= 1., and b is |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4243 // integral. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4244 |
7869 | 4245 static void |
4246 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
|
4247 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4248 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4249 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4250 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4251 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4252 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4253 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4254 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4255 double l = std::log10 (std::abs (x)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4256 double r = std::fmod (l, 1.); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4257 a = std::pow (10.0, r); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4258 b = static_cast<int> (l-r); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4259 if (a < 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4260 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4261 a *= 10; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4262 b -= 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4263 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4264 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4265 if (x < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4266 a = -a; |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4267 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4268 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4269 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4270 // 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
|
4271 // 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
|
4272 // FIXME -- add log ticks |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4273 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4274 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4275 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
|
4276 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4277 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4278 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4279 // 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
|
4280 // 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
|
4281 // 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
|
4282 // 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
|
4283 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4284 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4285 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4286 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4287 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
|
4288 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4289 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
|
4290 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
|
4291 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
|
4292 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4293 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4294 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4295 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4296 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4297 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4298 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4299 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4300 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4301 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4302 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
|
4303 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4304 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4305 |
7222 | 4306 // Attempt to make "nice" limits from the actual max and min of the |
4307 // data. For log plots, we will also use the smallest strictly positive | |
4308 // value. | |
4309 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4310 Matrix |
7869 | 4311 axes::properties::get_axis_limits (double xmin, double xmax, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4312 double min_pos, bool logscale) |
7222 | 4313 { |
4314 Matrix retval; | |
4315 | |
4316 double min_val = xmin; | |
4317 double max_val = xmax; | |
4318 | |
4319 if (! (xisinf (min_val) || xisinf (max_val))) | |
4320 { | |
4321 if (logscale) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4322 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4323 if (xisinf (min_pos)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4324 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4325 // warning ("axis: logscale with no positive values to plot"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4326 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4327 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4328 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4329 if (min_val <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4331 warning ("axis: omitting nonpositive data in log plot"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4332 min_val = min_pos; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4333 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4334 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4335 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
|
4336 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4337 min_val *= 0.9; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4338 max_val *= 1.1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4339 } |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4340 min_val = pow (10, gnulib::floor (log10 (min_val))); |
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4341 max_val = pow (10, std::ceil (log10 (max_val))); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4342 } |
7222 | 4343 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4344 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4345 if (min_val == 0 && max_val == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4346 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4347 min_val = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4348 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4349 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4350 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4351 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
|
4352 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4353 min_val -= 0.1 * std::abs (min_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4354 max_val += 0.1 * std::abs (max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4355 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4356 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4357 double tick_sep = calc_tick_sep (min_val , max_val); |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4358 min_val = tick_sep * gnulib::floor (min_val / tick_sep); |
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4359 max_val = tick_sep * std::ceil (max_val / tick_sep); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4360 } |
7222 | 4361 } |
4362 | |
4363 retval.resize (1, 2); | |
4364 | |
4365 retval(0) = min_val; | |
4366 retval(1) = max_val; | |
4367 | |
4368 return retval; | |
4369 } | |
4370 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4371 void |
7869 | 4372 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
|
4373 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
|
4374 array_property& mticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4375 bool limmode_is_auto, bool is_logscale) |
7446 | 4376 { |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4377 // FIXME -- add log ticks and lims |
7446 | 4378 |
4379 if (lims.get ().is_empty ()) | |
4380 return; | |
4381 | |
4382 double lo = (lims.get ().matrix_value ()) (0); | |
4383 double hi = (lims.get ().matrix_value ()) (1); | |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4384 // 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
|
4385 if (hi < lo) |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4386 { |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4387 double tmp = hi; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4388 hi = lo; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4389 lo = tmp; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4390 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4391 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4392 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4393 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4394 // FIXME we should check for negtives here |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4395 hi = std::log10 (hi); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4396 lo = std::log10 (lo); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4397 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4398 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4399 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
|
4400 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4401 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
|
4402 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
|
4403 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4404 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4405 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4406 // 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
|
4407 Matrix tmp_lims (1,2); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4408 tmp_lims(0) = tick_sep * i1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4409 tmp_lims(1) = tick_sep * i2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4410 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4411 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4412 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4413 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
|
4414 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
|
4415 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
|
4416 tmp_lims(0) = std::pow (10., lo); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4417 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4418 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4419 } |
7446 | 4420 else |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4421 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4422 // adjust min and max tics if they are out of limits |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4423 i1 = static_cast<int> (std::ceil (lo / tick_sep)); |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
4424 i2 = static_cast<int> (gnulib::floor (hi / tick_sep)); |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4425 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4426 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4427 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
|
4428 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
|
4429 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4430 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
|
4431 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4432 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
|
4433 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4434 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4435 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
|
4436 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4437 int n = is_logscale ? 9 : 4; |
12157
0b9c1a7e350a
fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents:
12126
diff
changeset
|
4438 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
|
4439 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4440 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
|
4441 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4442 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
|
4443 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
|
4444 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4445 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
|
4446 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4447 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
4448 mticks = tmp_mticks; |
7446 | 4449 } |
4450 | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4451 void |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4452 axes::properties::calc_ticklabels (const array_property& ticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4453 any_property& labels, bool /*logscale*/) |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4454 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4455 Matrix values = ticks.get ().matrix_value (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4456 Cell c (values.dims ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4457 std::ostringstream os; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4458 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4459 for (int i = 0; i < values.numel (); i++) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4460 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4461 os.str (std::string ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4462 os << values(i); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4463 c(i) = os.str (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4464 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4465 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4466 labels = c; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4467 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4468 |
9455 | 4469 void |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4470 get_children_limits (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4471 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
|
4472 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4473 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
|
4474 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4475 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
|
4476 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4477 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
|
4478 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
|
4479 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4480 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
|
4481 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4482 if (obj.is_xliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4483 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4484 octave_value lim = obj.get_xlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4485 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4486 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4487 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4488 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4489 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4490 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4491 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
|
4492 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
|
4493 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4494 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
|
4495 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4496 if (obj.is_yliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4497 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4498 octave_value lim = obj.get_ylim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4499 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4500 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4501 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4502 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4503 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4504 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4505 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
|
4506 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
|
4507 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4508 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
|
4509 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4510 if (obj.is_zliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4511 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4512 octave_value lim = obj.get_zlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4513 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4514 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4515 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4516 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4517 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4518 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4519 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
|
4520 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
|
4521 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4522 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
|
4523 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4524 if (obj.is_climinclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4525 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4526 octave_value lim = obj.get_clim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4527 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4528 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4529 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4530 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4531 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4532 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4533 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
|
4534 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
|
4535 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4536 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
|
4537 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4538 if (obj.is_aliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4539 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4540 octave_value lim = obj.get_alim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4541 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4542 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4543 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4544 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4545 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4546 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4547 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4548 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4549 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4550 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4551 |
7222 | 4552 static bool updating_axis_limits = false; |
4553 | |
7214 | 4554 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4555 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
|
4556 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
|
4557 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4558 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
|
4559 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4560 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4561 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
|
4562 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4563 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
|
4564 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
|
4565 double min_pos = octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4566 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4567 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
|
4568 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4569 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4570 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4571 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4572 #define FIX_LIMITS \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4573 if (limits.numel() == 3) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4574 { \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4575 val = limits(0); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4576 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
|
4577 min_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4578 val = limits(1); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4579 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
|
4580 max_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4581 val = limits(2); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4582 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
|
4583 min_pos = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4584 } \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4585 else \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4586 { \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4587 limits.resize(3, 1); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4588 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
|
4589 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
|
4590 limits(2) = min_pos; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4591 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4592 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4593 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
|
4594 || 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
|
4595 || axis_type == "xlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4596 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4597 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
|
4598 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4599 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
|
4600 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4601 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4602 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4603 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4604 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4605 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
|
4606 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4607 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4608 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4609 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4610 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
|
4611 || 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
|
4612 || axis_type == "ylim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4613 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4614 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
|
4615 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4616 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
|
4617 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4618 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4619 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4620 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4621 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4622 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
|
4623 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4624 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4625 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4626 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4627 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
|
4628 || 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
|
4629 || axis_type == "zlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4630 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4631 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
|
4632 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4633 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
|
4634 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4635 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4636 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4637 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4638 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4639 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
|
4640 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4641 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4642 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4643 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4644 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
|
4645 || 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
|
4646 || axis_type == "clim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4647 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4648 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
|
4649 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4650 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
|
4651 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4652 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4653 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4654 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4655 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
|
4656 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4657 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
|
4658 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4659 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4660 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
|
4661 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
|
4662 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4663 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
|
4664 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4665 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
|
4666 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
|
4667 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4668 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4669 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4670 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4671 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4672 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
|
4673 || 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
|
4674 || axis_type == "alim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4675 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4676 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
|
4677 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4678 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
|
4679 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4680 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4681 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4682 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4683 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
|
4684 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4685 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
|
4686 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4687 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4688 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
|
4689 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
|
4690 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4691 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
|
4692 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4693 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
|
4694 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
|
4695 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4696 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4697 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4698 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4699 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4700 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4701 #undef FIX_LIMITS |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4702 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4703 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4704 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
|
4705 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4706 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
|
4707 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4708 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4709 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4710 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4711 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
|
4712 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
|
4713 xproperties.update_xlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4714 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4715 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4716 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4717 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
|
4718 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
|
4719 xproperties.update_ylim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4720 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4721 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4722 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4723 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
|
4724 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
|
4725 xproperties.update_zlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4726 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4727 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4728 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4729 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
|
4730 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
|
4731 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4732 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4733 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4734 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
|
4735 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
|
4736 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4737 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4738 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4739 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4740 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4741 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4742 xproperties.update_transform (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4743 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4744 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4745 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4746 void |
7222 | 4747 axes::update_axis_limits (const std::string& axis_type) |
7214 | 4748 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4749 if (updating_axis_limits || updating_aspectratios) |
7222 | 4750 return; |
4751 | |
4752 Matrix kids = xproperties.get_children (); | |
4753 | |
4754 double min_val = octave_Inf; | |
4755 double max_val = -octave_Inf; | |
4756 double min_pos = octave_Inf; | |
4757 | |
4758 char update_type = 0; | |
4759 | |
4760 Matrix limits; | |
4761 | |
4762 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
|
4763 || 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
|
4764 || axis_type == "xlim") |
7222 | 4765 { |
7363 | 4766 if (xproperties.xlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4767 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4768 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4769 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4770 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4771 xproperties.xscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4772 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4773 update_type = 'x'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4774 } |
7222 | 4775 } |
4776 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
|
4777 || axis_type == "ylimmode" || axis_type == "yliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4778 || axis_type == "ylim") |
7222 | 4779 { |
7363 | 4780 if (xproperties.ylimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4781 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4782 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4783 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4784 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4785 xproperties.yscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4786 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4787 update_type = 'y'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4788 } |
7222 | 4789 } |
4790 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
|
4791 || axis_type == "zlimmode" || axis_type == "zliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4792 || axis_type == "zlim") |
7222 | 4793 { |
7363 | 4794 if (xproperties.zlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4795 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4796 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4797 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4798 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4799 xproperties.zscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4800 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4801 update_type = 'z'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4802 } |
7222 | 4803 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4804 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
|
4805 || axis_type == "cdatamapping" || axis_type == "climinclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4806 || axis_type == "clim") |
7222 | 4807 { |
7363 | 4808 if (xproperties.climmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4809 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4810 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4811 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4812 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4813 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4814 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4815 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4816 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4817 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4818 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4819 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4820 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4821 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4822 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4823 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4824 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4825 update_type = 'c'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4826 } |
7222 | 4827 |
4828 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4829 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
|
4830 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4831 || 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
|
4832 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4833 if (xproperties.alimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4834 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4835 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4836 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4837 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4838 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4839 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4840 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4841 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4842 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4843 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4844 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4845 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4846 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4847 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4848 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4849 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4850 update_type = 'a'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4851 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4852 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4853 } |
7222 | 4854 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4855 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4856 frame.protect_var (updating_axis_limits); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4857 |
7222 | 4858 updating_axis_limits = true; |
4859 | |
4860 switch (update_type) | |
4861 { | |
4862 case 'x': | |
4863 xproperties.set_xlim (limits); | |
4864 xproperties.set_xlimmode ("auto"); | |
7446 | 4865 xproperties.update_xlim (); |
7222 | 4866 break; |
4867 | |
4868 case 'y': | |
4869 xproperties.set_ylim (limits); | |
4870 xproperties.set_ylimmode ("auto"); | |
7446 | 4871 xproperties.update_ylim (); |
7222 | 4872 break; |
4873 | |
4874 case 'z': | |
4875 xproperties.set_zlim (limits); | |
4876 xproperties.set_zlimmode ("auto"); | |
7446 | 4877 xproperties.update_zlim (); |
7222 | 4878 break; |
4879 | |
4880 case 'c': | |
4881 xproperties.set_clim (limits); | |
4882 xproperties.set_climmode ("auto"); | |
4883 break; | |
4884 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4885 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
|
4886 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
|
4887 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
|
4888 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4889 |
7222 | 4890 default: |
4891 break; | |
4892 } | |
4893 | |
7427 | 4894 xproperties.update_transform (); |
7214 | 4895 } |
4896 | |
9455 | 4897 inline |
4898 double force_in_range (const double x, const double lower, const double upper) | |
4899 { | |
4900 if (x < lower) | |
4901 { return lower; } | |
4902 else if (x > upper) | |
4903 { return upper; } | |
4904 else | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4905 { return x; } |
9455 | 4906 } |
4907 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4908 void |
9455 | 4909 axes::properties::zoom_about_point (double x, double y, double factor, |
4910 bool push_to_zoom_stack) | |
4911 { | |
4912 // FIXME: Do we need error checking here? | |
4913 Matrix xlims = get_xlim ().matrix_value (); | |
4914 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4915 |
9455 | 4916 // Get children axes limits |
4917 Matrix kids = get_children (); | |
4918 double minx = octave_Inf; | |
4919 double maxx = -octave_Inf; | |
4920 double min_pos_x = octave_Inf; | |
4921 get_children_limits (minx, maxx, min_pos_x, kids, 'x'); | |
4922 | |
4923 double miny = octave_Inf; | |
4924 double maxy = -octave_Inf; | |
4925 double min_pos_y = octave_Inf; | |
4926 get_children_limits (miny, maxy, min_pos_y, kids, 'y'); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4927 |
9455 | 4928 // Perform the zooming |
4929 xlims (0) = x + factor * (xlims (0) - x); | |
4930 xlims (1) = x + factor * (xlims (1) - x); | |
4931 ylims (0) = y + factor * (ylims (0) - y); | |
4932 ylims (1) = y + factor * (ylims (1) - y); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4933 |
9455 | 4934 zoom (xlims, ylims, push_to_zoom_stack); |
4935 } | |
4936 | |
4937 void | |
4938 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack) | |
4939 { | |
4940 if (push_to_zoom_stack) | |
4941 { | |
4942 zoom_stack.push_front (xlimmode.get ()); | |
4943 zoom_stack.push_front (xlim.get ()); | |
4944 zoom_stack.push_front (ylimmode.get ()); | |
4945 zoom_stack.push_front (ylim.get ()); | |
4946 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4947 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4948 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4949 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4950 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4951 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4952 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4953 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4954 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4955 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4956 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4957 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4958 void |
9455 | 4959 axes::properties::translate_view (double delta_x, double delta_y) |
4960 { | |
4961 // FIXME: Do we need error checking here? | |
4962 Matrix xlims = get_xlim ().matrix_value (); | |
4963 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4964 |
9455 | 4965 // Get children axes limits |
4966 Matrix kids = get_children (); | |
4967 double minx = octave_Inf; | |
4968 double maxx = -octave_Inf; | |
4969 double min_pos_x = octave_Inf; | |
4970 get_children_limits (minx, maxx, min_pos_x, kids, 'x'); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4971 |
9455 | 4972 double miny = octave_Inf; |
4973 double maxy = -octave_Inf; | |
4974 double min_pos_y = octave_Inf; | |
4975 get_children_limits (miny, maxy, min_pos_y, kids, 'y'); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4976 |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4977 xlims (0) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4978 xlims (1) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4979 ylims (0) += delta_y; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4980 ylims (1) += delta_y; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4981 |
9455 | 4982 zoom (xlims, ylims, false); |
4983 } | |
4984 | |
4985 void | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4986 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
|
4987 { |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4988 Matrix v = get_view ().matrix_value (); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4989 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4990 v (1) += delta_el; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4991 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4992 if(v(1) > 90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4993 v(1) = 90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4994 if(v(1) < -90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4995 v(1) = -90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4996 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4997 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
|
4998 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4999 set_view(v); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
5000 update_transform(); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
5001 } |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
5002 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
5003 void |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5004 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5005 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5006 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5007 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5008 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5009 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5010 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5011 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5012 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5013 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5014 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5015 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5016 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5017 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5018 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5019 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5020 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5021 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5022 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5023 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5024 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5025 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5026 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5027 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5028 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5029 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5030 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
5031 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5032 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5033 axes::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5034 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
5035 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5036 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5037 |
7363 | 5038 // --------------------------------------------------------------------- |
5039 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5040 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5041 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
|
5042 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5043 Matrix m (1, 3); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5044 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5045 m(0) = xdata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5046 m(1) = xdata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5047 m(2) = xdata.min_pos (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5048 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5049 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
|
5050 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5051 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5052 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5053 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
|
5054 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5055 Matrix m (1, 3); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5056 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5057 m(0) = ydata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5058 m(1) = ydata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
5059 m(2) = ydata.min_pos (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5060 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5061 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
|
5062 } |
6406 | 5063 |
5064 // --------------------------------------------------------------------- | |
5065 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5066 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5067 text::properties::get_data_position (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5068 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5069 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5070 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5071 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5072 pos = convert_text_position (pos, *this, get_units (), "data"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5073 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5074 return pos; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5075 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5076 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5077 Matrix |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5078 text::properties::get_extent_matrix (void) const |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5079 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5080 return extent.get ().matrix_value (); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5081 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5082 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5083 octave_value |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5084 text::properties::get_extent (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5085 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5086 Matrix m = extent.get ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5087 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5088 return convert_text_position (m, *this, "pixels", get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5089 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5090 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5091 void |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5092 text::properties::update_text_extent (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5093 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5094 #ifdef HAVE_FREETYPE |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5095 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5096 // FIXME: font and color should be set only when modified, for efficiency |
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
|
5097 #ifdef HAVE_FONTCONFIG |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5098 renderer.set_font (get ("fontname").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5099 get ("fontweight").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5100 get ("fontangle").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5101 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
|
5102 #endif |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5103 renderer.set_color (get_color_rgb ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5104 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5105 int halign = 0, valign = 0; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5106 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5107 if (horizontalalignment_is ("center")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5108 halign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5109 else if (horizontalalignment_is ("right")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5110 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5111 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5112 if (verticalalignment_is ("top")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5113 valign = 2; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5114 else if (verticalalignment_is ("baseline")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5115 valign = 3; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5116 else if (verticalalignment_is ("middle")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5117 valign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5118 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5119 Matrix bbox; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5120 // FIXME: string should be parsed only when modified, for efficiency |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5121 renderer.text_to_pixels (get_string (), pixels, bbox, |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5122 halign, valign, get_rotation ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5123 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
5124 set_extent (bbox); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5125 #endif |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5126 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5127 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5128 void |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5129 text::properties::update_units (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5130 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5131 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5132 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5133 set_xliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5134 set_yliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5135 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5136 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5137 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5138 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5139 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5140 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
|
5141 // 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
|
5142 // 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
|
5143 // to "off". |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5144 set_position (pos); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5145 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5146 if (units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5147 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5148 set_xliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5149 set_yliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5150 // FIXME: see above |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5151 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5152 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5153 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5154 cached_units = get_units (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5155 } |
6406 | 5156 |
5157 // --------------------------------------------------------------------- | |
5158 | |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
5159 octave_value |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
5160 image::properties::get_color_data (void) const |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
5161 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
5162 return convert_cdata (*this, get_cdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5163 cdatamapping_is ("scaled"), 3); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
5164 } |
6406 | 5165 |
5166 // --------------------------------------------------------------------- | |
5167 | |
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
|
5168 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
|
5169 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
|
5170 { |
11168
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
5171 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
|
5172 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
|
5173 return Matrix (); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
5174 else |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
5175 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
|
5176 } |
6807 | 5177 |
5178 // --------------------------------------------------------------------- | |
5179 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5180 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5181 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
|
5182 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5183 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
|
5184 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5185 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5186 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5187 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
|
5188 double x2, double y2, double z2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5189 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
|
5190 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5191 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
|
5192 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
|
5193 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
|
5194 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5195 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5196 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5197 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
|
5198 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5199 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5200 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5201 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
|
5202 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
|
5203 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
|
5204 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5205 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5206 int p = z.columns (), q = z.rows (); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5207 int i1 = 0, i2 = 0, i3 = 0; |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5208 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
|
5209 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5210 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
|
5211 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
|
5212 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5213 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
|
5214 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5215 for (int i = 0; i < p; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5216 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5217 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5218 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5219 i1 = i - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5220 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5221 i3 = i + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5222 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5223 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5224 for (int j = 0; j < q; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5225 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5226 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5227 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5228 j1 = j - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5229 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5230 j3 = j + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5231 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5232 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5233 double& nx = n(j, i, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5234 double& ny = n(j, i, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5235 double& nz = n(j, i, 2); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5236 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5237 if ((j > 0) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5238 // upper left quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5239 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
|
5240 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
|
5241 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5242 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5243 if ((j > 0) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5244 // upper right quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5245 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
|
5246 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
|
5247 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5248 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5249 if ((j < (q - 1)) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5250 // lower left quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5251 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
|
5252 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
|
5253 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5254 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5255 if ((j < (q - 1)) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5256 // lower right quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5257 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
|
5258 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
|
5259 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5260 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
5261 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
|
5262 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5263 nx /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5264 ny /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5265 nz /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5266 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5267 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5268 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5269 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5270 } |
6406 | 5271 |
5272 // --------------------------------------------------------------------- | |
5273 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5274 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5275 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
|
5276 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5277 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
|
5278 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5279 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5280 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5281 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
|
5282 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
|
5283 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
|
5284 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
|
5285 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
|
5286 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5287 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5288 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5289 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5290 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
|
5291 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5292 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
|
5293 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5294 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5295 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5296 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
|
5297 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
|
5298 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
|
5299 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
|
5300 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
|
5301 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5302 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5303 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5304 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
|
5305 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5306 void |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5307 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
|
5308 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
|
5309 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5310 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
|
5311 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5312 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5313 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
|
5314 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5315 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
|
5316 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
|
5317 double min_pos = octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5318 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5319 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5320 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5321 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5322 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
|
5323 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5324 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
|
5325 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5326 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
|
5327 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5328 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5329 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
|
5330 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5331 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
|
5332 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5333 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5334 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
|
5335 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5336 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
|
5337 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5338 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5339 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
|
5340 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5341 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
|
5342 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5343 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5344 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
|
5345 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5346 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
|
5347 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5348 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5349 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5350 if (limits.numel() == 3) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5351 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5352 val = limits(0); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5353 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
|
5354 min_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5355 val = limits(1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5356 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
|
5357 max_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5358 val = limits(2); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5359 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
|
5360 min_pos = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5361 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5362 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5363 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5364 limits.resize(3,1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5365 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
|
5366 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
|
5367 limits(2) = min_pos; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5368 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5369 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5370 get_children_limits (min_val, max_val, min_pos, kids, update_type); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5371 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5372 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5373 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
|
5374 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5375 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
|
5376 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5377 if (limits(0) != min_val || limits(1) != max_val || limits(2) != min_pos) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5378 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5379 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
|
5380 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
|
5381 limits(2) = min_pos; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5382 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5383 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5384 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5385 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5386 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
|
5387 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5388 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5389 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5390 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
|
5391 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5392 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5393 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5394 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
|
5395 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5396 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5397 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5398 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
|
5399 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5400 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5401 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5402 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
|
5403 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5404 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5405 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5406 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5407 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5408 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5409 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
|
5410 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5411 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5412 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5413 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5414 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5415 { |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5416 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
|
5417 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5418 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5419 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5420 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5421 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5422 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5423 double min_pos = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5424 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5425 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5426 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5427 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5428 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5429 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5430 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5431 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5432 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5433 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5434 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5435 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5436 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5437 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5438 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5439 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5440 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5441 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5442 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5443 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5444 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5445 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5446 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5447 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5448 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5449 update_type = 'c'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5450 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5451 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5452 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5453 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5454 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5455 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5456 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5457 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5458 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5459 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
|
5460 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5461 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
|
5462 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5463 Matrix limits (1, 3, 0.0); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5464 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5465 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5466 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5467 limits(2) = min_pos; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5468 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5469 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5470 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5471 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5472 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5473 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5474 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5475 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5476 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5477 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5478 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5479 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5480 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5481 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5482 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5483 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5484 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5485 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5486 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5487 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5488 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5489 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5490 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5491 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5492 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5493 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5494 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5495 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5496 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5497 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5498 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5499 |
6406 | 5500 octave_value |
7189 | 5501 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 5502 { |
5503 graphics_handle parent = get_parent (); | |
5504 graphics_object parent_obj = gh_manager::get_object (parent); | |
5505 | |
5506 return parent_obj.get_default (type () + name); | |
5507 } | |
5508 | |
5509 octave_value | |
7189 | 5510 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 5511 { |
5512 graphics_object parent_obj = gh_manager::get_object (0); | |
5513 | |
5514 return parent_obj.get_factory_default (type () + name); | |
5515 } | |
5516 | |
7286 | 5517 // We use a random value for the handle to avoid issues with plots and |
5518 // scalar values for the first argument. | |
6406 | 5519 gh_manager::gh_manager (void) |
7286 | 5520 : handle_map (), handle_free_list (), |
5521 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)) | |
6406 | 5522 { |
5523 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
5524 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5525 // Make sure the default graphics toolkit is registered. |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5526 graphics_toolkit::default_toolkit (); |
6406 | 5527 } |
5528 | |
5529 graphics_handle | |
5530 gh_manager::do_make_graphics_handle (const std::string& go_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5531 const graphics_handle& p, bool do_createfcn) |
6406 | 5532 { |
5533 graphics_handle h = get_handle (go_name); | |
5534 | |
5535 base_graphics_object *go = 0; | |
5536 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
5537 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
|
5538 |
6406 | 5539 if (go) |
7370 | 5540 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5541 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5542 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5543 handle_map[h] = obj; |
7370 | 5544 if (do_createfcn) |
5545 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5546 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5547 // Notify graphics toolkit. |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5548 graphics_toolkit toolkit = go->get_toolkit (); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5549 if (toolkit) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5550 toolkit.initialize (obj); |
7370 | 5551 } |
6406 | 5552 else |
5553 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
|
5554 go_name.c_str ()); |
6406 | 5555 |
5556 return h; | |
5557 } | |
5558 | |
5559 graphics_handle | |
5560 gh_manager::do_make_figure_handle (double val) | |
5561 { | |
5562 graphics_handle h = val; | |
5563 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5564 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
|
5565 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5566 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5567 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5568 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5569 // Notify graphics toolkit. |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5570 graphics_toolkit toolkit = go->get_toolkit (); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5571 if (toolkit) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
5572 toolkit.initialize (obj); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5573 |
6406 | 5574 return h; |
5575 } | |
5576 | |
5577 void | |
5578 gh_manager::do_push_figure (const graphics_handle& h) | |
5579 { | |
5580 do_pop_figure (h); | |
5581 | |
5582 figure_list.push_front (h); | |
5583 } | |
5584 | |
5585 void | |
5586 gh_manager::do_pop_figure (const graphics_handle& h) | |
5587 { | |
5588 for (figure_list_iterator p = figure_list.begin (); | |
5589 p != figure_list.end (); | |
5590 p++) | |
5591 { | |
5592 if (*p == h) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5593 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5594 figure_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5595 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5596 } |
6406 | 5597 } |
5598 } | |
5599 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5600 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5601 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
|
5602 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5603 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5604 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
|
5605 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
|
5606 : base_graphics_event (), handle (h), callback_name (name), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5607 callback_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5608 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5609 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5610 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5611 gh_manager::execute_callback (handle, callback_name, callback_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5612 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5613 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5614 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5615 callback_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5616 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5617 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5618 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5619 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5620 std::string callback_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5621 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5622 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5623 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5624 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5625 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
|
5626 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5627 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5628 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
|
5629 : base_graphics_event (), function (fcn), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5630 function_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5631 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5632 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5633 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5634 function (function_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5635 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5636 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5637 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5638 function_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5639 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5640 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5641 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5642 graphics_event::event_fcn function; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5643 void* function_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5644 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5645 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5646 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5647 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
|
5648 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5649 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5650 set_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
|
5651 const octave_value& value) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5652 : base_graphics_event (), handle (h), property_name (name), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5653 property_value (value) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5654 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5655 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5656 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5657 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5658 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5659 xset (handle, property_name, property_value); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5660 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5661 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5662 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5663 set_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5664 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5665 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5666 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5667 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5668 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5669 octave_value property_value; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5670 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5671 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5672 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5673 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
|
5674 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5675 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5676 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5677 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5678 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5679 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
|
5680 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5681 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5682 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5683 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5684 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5685 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
|
5686 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5687 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5688 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5689 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5690 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
|
5691 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5692 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5693 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5694 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5695 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5696 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
|
5697 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5698 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5699 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5700 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5701 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5702 e.rep = new set_event (h, name, data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5703 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5704 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5705 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5706 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5707 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5708 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5709 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5710 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
|
5711 root_figure::properties& props = |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5712 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
|
5713 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5714 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
|
5715 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5716 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5717 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5718 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5719 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5720 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5721 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5722 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5723 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5724 xset_gcbo (callback_objects.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5725 ? graphics_handle () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5726 : callback_objects.front ().get_handle ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5727 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5728 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5729 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5730 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
|
5731 const octave_value& cb_arg, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5732 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5733 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5734 octave_value_list args; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5735 octave_function *fcn = 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5736 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5737 args(0) = h.as_octave_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5738 if (data.is_defined ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5739 args(1) = data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5740 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5741 args(1) = Matrix (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5742 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
5743 unwind_protect_safe frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
5744 frame.add_fcn (gh_manager::restore_gcbo); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5745 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5746 if (true) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5747 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5748 gh_manager::autolock guard; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5749 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5750 callback_objects.push_front (get_object (h)); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5751 xset_gcbo (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5752 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5753 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5754 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5755 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5756 // Copy CB because "function_value" method is non-const. |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5757 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5758 octave_value cb = cb_arg; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5759 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5760 if (cb.is_function_handle ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5761 fcn = cb.function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5762 else if (cb.is_string ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5763 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5764 int status; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5765 std::string s = cb.string_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5766 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5767 eval_string (s, false, status); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5768 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5769 else if (cb.is_cell () && cb.length () > 0 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5770 && (cb.rows () == 1 || cb.columns () == 1) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5771 && cb.cell_value ()(0).is_function_handle ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5772 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5773 Cell c = cb.cell_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5774 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5775 fcn = c(0).function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5776 if (! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5777 { |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
5778 for (int i = 1; i < c.length () ; i++) |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
5779 args(1+i) = c(i); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5780 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5781 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5782 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5783 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5784 std::string nm = cb.class_name (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5785 error ("trying to execute non-executable object (class = %s)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5786 nm.c_str ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5787 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5788 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5789 if (fcn && ! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5790 feval (fcn, args); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5791 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5792 END_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5793 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5794 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5795 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5796 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
|
5797 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5798 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5799 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5800 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
|
5801 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5802 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5803 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5804 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
|
5805 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5806 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5807 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5808 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5809 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5810 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5811 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5812 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5813 if (callback_objects.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5814 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
|
5815 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5816 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5817 const graphics_object& current = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5818 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5819 if (current.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5820 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
|
5821 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5822 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5823 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
|
5824 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5825 if (busy_action.compare ("queue")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5826 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
|
5827 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5828 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5829 caseless_str cname (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5830 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5831 if (cname.compare ("deletefcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5832 || cname.compare ("createfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5833 || (go.isa ("figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5834 && (cname.compare ("closerequestfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5835 || cname.compare ("resizefcn")))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5836 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
|
5837 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5838 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5839 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5840 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5841 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5842 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5843 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5844 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
|
5845 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5846 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5847 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5848 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
|
5849 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5850 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5851 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5852 gh_manager::do_post_set (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
|
5853 const octave_value& value) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5854 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5855 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5856 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5857 do_post_event (graphics_event::create_set_event (h, name, value)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5858 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5859 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5860 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5861 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
|
5862 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5863 graphics_event e; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5864 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5865 do |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5866 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5867 e = graphics_event (); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5868 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5869 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5870 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5871 if (! event_queue.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5872 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5873 if (callback_objects.empty () || force) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5874 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5875 e = event_queue.front (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5876 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5877 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5878 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5879 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5880 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5881 const graphics_object& go = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5882 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5883 if (go.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5884 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5885 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5886 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5887 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5888 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5889 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5890 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5891 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5892 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5893 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5894 if (e.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5895 e.execute (); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5896 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5897 while (e.ok ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5898 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5899 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5900 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5901 if (event_queue.empty ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5902 command_editor::remove_event_hook (gh_manager::process_events); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5903 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5904 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5905 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5906 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5907 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5908 |
6406 | 5909 property_list::plist_map_type |
5910 root_figure::init_factory_properties (void) | |
5911 { | |
5912 property_list::plist_map_type plist_map; | |
5913 | |
6844 | 5914 plist_map["figure"] = figure::properties::factory_defaults (); |
5915 plist_map["axes"] = axes::properties::factory_defaults (); | |
5916 plist_map["line"] = line::properties::factory_defaults (); | |
5917 plist_map["text"] = text::properties::factory_defaults (); | |
5918 plist_map["image"] = image::properties::factory_defaults (); | |
5919 plist_map["patch"] = patch::properties::factory_defaults (); | |
5920 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5921 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
|
5922 plist_map["uimenu"] = uimenu::properties::factory_defaults (); |
6406 | 5923 |
5924 return plist_map; | |
5925 } | |
5926 | |
5927 // --------------------------------------------------------------------- | |
5928 | |
5929 DEFUN (ishandle, args, , | |
5930 "-*- texinfo -*-\n\ | |
6678 | 5931 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 5932 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
|
5933 @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
|
5934 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
|
5935 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
|
5936 @seealso{isfigure}\n\ |
6406 | 5937 @end deftypefn") |
5938 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5939 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5940 |
6406 | 5941 octave_value retval; |
5942 | |
5943 if (args.length () == 1) | |
5944 retval = is_handle (args(0)); | |
5945 else | |
5946 print_usage (); | |
5947 | |
5948 return retval; | |
5949 } | |
5950 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5951 DEFUN (reset, args, , |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5952 "-*- texinfo -*-\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5953 @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
|
5954 Remove any defaults set for the handle @var{h}. The default figure\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5955 properties \"position\", \"units\", \"windowstyle\" and\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5956 \"paperunits\" and the default axes properties \"position\" and \"units\"\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5957 are not reset.\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5958 @end deftypefn") |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5959 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5960 int nargin = args.length (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5961 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5962 if (nargin != 1) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5963 print_usage (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5964 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5965 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5966 // get vector of graphics handles |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5967 ColumnVector hcv (args(0).vector_value ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5968 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5969 if (! error_state) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5970 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5971 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5972 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
|
5973 gh_manager::get_object (hcv(n)).reset_default_properties (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5974 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5975 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5976 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5977 return octave_value (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5978 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5979 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5980 DEFUN (set, args, nargout, |
6406 | 5981 "-*- texinfo -*-\n\ |
10840 | 5982 @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
|
5983 @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
|
5984 @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
|
5985 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
|
5986 handles) @var{h}.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5987 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
|
5988 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5989 @itemize\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5990 @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
|
5991 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5992 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
|
5993 @var{value} is a value of the appropriate type for the property.\n\ |
10840 | 5994 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5995 @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
|
5996 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
|
5997 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5998 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
|
5999 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
|
6000 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
|
6001 @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
|
6002 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
|
6003 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
|
6004 the first row of @var{values} and so on.\n\ |
10840 | 6005 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6006 @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
|
6007 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6008 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
|
6009 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
|
6010 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
|
6011 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
|
6012 @end itemize\n\ |
6406 | 6013 @end deftypefn") |
6014 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6015 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6016 |
6406 | 6017 octave_value retval; |
6018 | |
6019 int nargin = args.length (); | |
6020 | |
6021 if (nargin > 0) | |
6022 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6023 // get vector of graphics handles |
6732 | 6024 ColumnVector hcv (args(0).vector_value ()); |
6406 | 6025 |
6026 if (! error_state) | |
6732 | 6027 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6028 bool request_drawnow = false; |
6733 | 6029 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6030 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6031 for (octave_idx_type n = 0; n < hcv.length (); n++) |
6732 | 6032 { |
6033 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 6034 |
6732 | 6035 if (obj) |
6036 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6037 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
|
6038 && args(2).is_cell ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6039 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6040 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
|
6041 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6042 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
|
6043 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
|
6044 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6045 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
|
6046 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6047 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
|
6048 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
|
6049 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6050 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6051 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6052 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
|
6053 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
|
6054 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6055 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6056 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6057 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6058 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
|
6059 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6060 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
|
6061 } |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6062 else if (nargin == 1) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6063 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6064 if (nargout != 0) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6065 retval = obj.values_as_struct (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6066 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6067 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6068 std::string s = obj.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6069 if (! error_state) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6070 octave_stdout << s; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6071 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
6072 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6073 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6074 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6075 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
|
6076 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6077 } |
6732 | 6078 } |
6079 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6080 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6081 error ("set: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6082 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6083 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6084 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6085 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6086 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6087 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6088 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
6089 } |
6733 | 6090 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6091 if (! error_state && request_drawnow) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6092 Vdrawnow_requested = true; |
6732 | 6093 } |
6406 | 6094 else |
6732 | 6095 error ("set: expecting graphics handle as first argument"); |
6406 | 6096 } |
6097 else | |
6098 print_usage (); | |
6099 | |
6100 return retval; | |
6101 } | |
6102 | |
6103 DEFUN (get, args, , | |
6104 "-*- texinfo -*-\n\ | |
6678 | 6105 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406 | 6106 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
6107 If @var{p} is omitted, return the complete property list for @var{h}.\n\ | |
6732 | 6108 If @var{h} is a vector, return a cell array including the property\n\ |
6109 values or lists respectively.\n\ | |
6406 | 6110 @end deftypefn") |
6111 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6112 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6113 |
6406 | 6114 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
|
6115 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6116 Cell vals; |
6406 | 6117 |
6118 int nargin = args.length (); | |
6119 | |
6120 if (nargin == 1 || nargin == 2) | |
6121 { | |
6732 | 6122 ColumnVector hcv (args(0).vector_value ()); |
6406 | 6123 |
6124 if (! error_state) | |
6732 | 6125 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6126 octave_idx_type len = hcv.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6127 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6128 vals.resize (dim_vector (len, 1)); |
6733 | 6129 |
6130 for (octave_idx_type n = 0; n < len; n++) | |
6732 | 6131 { |
6132 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 6133 |
6732 | 6134 if (obj) |
6135 { | |
6136 if (nargin == 1) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6137 vals(n) = obj.get (); |
6732 | 6138 else |
6139 { | |
7189 | 6140 caseless_str property = args(1).string_value (); |
6406 | 6141 |
6732 | 6142 if (! error_state) |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6143 vals(n) = obj.get (property); |
6732 | 6144 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6145 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6146 error ("get: expecting property name as second argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6147 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6148 } |
6732 | 6149 } |
6150 } | |
6151 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6152 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6153 error ("get: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6154 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6155 } |
6732 | 6156 } |
6157 } | |
6406 | 6158 else |
6732 | 6159 error ("get: expecting graphics handle as first argument"); |
6406 | 6160 } |
6161 else | |
6162 print_usage (); | |
6163 | |
6733 | 6164 if (! error_state) |
6732 | 6165 { |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6166 octave_idx_type len = vals.numel (); |
6733 | 6167 |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6168 if (len == 0) |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6169 retval = Matrix (); |
6733 | 6170 else if (len == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6171 retval = vals(0); |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6172 else |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6173 retval = vals; |
6732 | 6174 } |
6175 | |
6406 | 6176 return retval; |
6177 } | |
6178 | |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6179 /* |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6180 %!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
|
6181 */ |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
6182 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
6183 // 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
|
6184 // 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
|
6185 // 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
|
6186 |
7379 | 6187 DEFUN (__get__, args, , |
6188 "-*- texinfo -*-\n\ | |
6189 @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
|
6190 Undocumented internal function.\n\ |
7379 | 6191 @end deftypefn") |
6192 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6193 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6194 |
7379 | 6195 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
|
6196 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6197 Cell vals; |
7379 | 6198 |
6199 int nargin = args.length (); | |
6200 | |
6201 if (nargin == 1) | |
6202 { | |
6203 ColumnVector hcv (args(0).vector_value ()); | |
6204 | |
6205 if (! error_state) | |
6206 { | |
6207 octave_idx_type len = hcv.length (); | |
6208 | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6209 vals.resize (dim_vector (len, 1)); |
7379 | 6210 |
6211 for (octave_idx_type n = 0; n < len; n++) | |
6212 { | |
6213 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6214 | |
6215 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
|
6216 vals(n) = obj.get (true); |
7379 | 6217 else |
6218 { | |
6219 error ("get: invalid handle (= %g)", hcv(n)); | |
6220 break; | |
6221 } | |
6222 } | |
6223 } | |
6224 else | |
6225 error ("get: expecting graphics handle as first argument"); | |
6226 } | |
6227 else | |
6228 print_usage (); | |
6229 | |
6230 if (! error_state) | |
6231 { | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
6232 octave_idx_type len = vals.numel (); |
7379 | 6233 |
6234 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
|
6235 retval = vals; |
7379 | 6236 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
|
6237 retval = vals(0); |
7379 | 6238 } |
6239 | |
6240 return retval; | |
6241 } | |
6242 | |
6406 | 6243 static octave_value |
6244 make_graphics_object (const std::string& go_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6245 const octave_value_list& args) |
6406 | 6246 { |
6247 octave_value retval; | |
6248 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6249 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6250 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6251 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6252 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6253 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6254 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6255 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6256 if (xargs(i).is_string () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6257 && p.compare (xargs(i).string_value ())) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6258 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6259 if (i < (xargs.length () - 1)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6260 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6261 val = xargs(i+1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6262 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6263 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6264 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6265 xargs = xargs.splice (i, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6266 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6267 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6268 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6269 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6270 error ("__go_%s__: missing value for parent property", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6271 go_name.c_str ()); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6272 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6273 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6274 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6275 val = args(0).double_value (); |
6406 | 6276 |
6277 if (! error_state) | |
6278 { | |
6279 graphics_handle parent = gh_manager::lookup (val); | |
6280 | |
7056 | 6281 if (parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6282 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6283 graphics_handle h |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6284 = gh_manager::make_graphics_handle (go_name, parent, false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6285 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6286 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6287 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6288 adopt (parent, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6289 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6290 xset (h, xargs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6291 xcreatefcn (h); |
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 retval = h.value (); |
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 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6296 Vdrawnow_requested = true; |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6299 error ("__go%s__: unable to create graphics handle", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6300 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6301 } |
6406 | 6302 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6303 error ("__go_%s__: invalid parent", go_name.c_str ()); |
6406 | 6304 } |
6305 else | |
6306 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
6307 | |
6308 return retval; | |
6309 } | |
6310 | |
6311 DEFUN (__go_figure__, args, , | |
6312 "-*- texinfo -*-\n\ | |
6313 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ | |
6945 | 6314 Undocumented internal function.\n\ |
6406 | 6315 @end deftypefn") |
6316 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6317 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6318 |
6406 | 6319 octave_value retval; |
6320 | |
6321 if (args.length () > 0) | |
6322 { | |
6323 double val = args(0).double_value (); | |
6324 | |
6325 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6326 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6327 if (is_figure (val)) |
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 graphics_handle h = gh_manager::lookup (val); |
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 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6332 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6333 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6334 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6335 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6336 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6337 graphics_handle h = octave_NaN; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6338 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6339 if (xisnan (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6340 h = gh_manager::make_graphics_handle ("figure", 0, false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6341 else if (val > 0 && D_NINT (val) == val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6342 h = gh_manager::make_figure_handle (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6343 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6344 error ("__go_figure__: invalid figure number"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6345 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6346 if (! error_state && h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6347 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6348 adopt (0, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6349 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6350 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6351 xcreatefcn (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6352 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6353 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6354 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6355 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6356 error ("__go_figure__: failed to create figure handle"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6357 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6358 } |
6406 | 6359 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6360 error ("__go_figure__: expecting figure number to be double value"); |
6406 | 6361 } |
6362 else | |
6363 print_usage (); | |
6364 | |
6365 return retval; | |
6366 } | |
6367 | |
6368 #define GO_BODY(TYPE) \ | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6369 gh_manager::autolock guard; \ |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6370 \ |
6406 | 6371 octave_value retval; \ |
6372 \ | |
6373 if (args.length () > 0) \ | |
6374 retval = make_graphics_object (#TYPE, args); \ | |
6375 else \ | |
6376 print_usage (); \ | |
6377 \ | |
6378 return retval | |
6379 | |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6380 int |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6381 calc_dimensions (const graphics_object& go) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6382 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6383 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6384 int nd = 2; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6385 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6386 if (go.isa ("surface")) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6387 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6388 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6389 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
|
6390 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6391 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6392 Matrix kids = go.get_properties().get_children (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6393 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6394 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
|
6395 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6396 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
|
6397 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6398 if (hnd.ok ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6399 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6400 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
|
6401 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6402 if (kid.valid_object()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6403 nd = calc_dimensions (kid); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6404 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6405 if (nd == 3) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6406 break; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6407 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6408 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6409 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6410 return nd; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6411 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6412 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6413 DEFUN (__calc_dimensions__, args, , |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6414 "-*- texinfo -*-\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6415 @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
|
6416 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
|
6417 object, whether 2 or 3.\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6418 @end deftypefn") |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6419 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6420 gh_manager::autolock guard; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6421 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6422 octave_value retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6423 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6424 int nargin = args.length (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6425 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6426 if (nargin == 1) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6427 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6428 double h = args(0).double_value (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6429 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6430 if (! error_state) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6431 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
|
6432 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6433 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
|
6434 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6435 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6436 print_usage (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6437 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6438 return retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6439 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6440 |
6406 | 6441 DEFUN (__go_axes__, args, , |
6442 "-*- texinfo -*-\n\ | |
6443 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ | |
6945 | 6444 Undocumented internal function.\n\ |
6406 | 6445 @end deftypefn") |
6446 { | |
6447 GO_BODY (axes); | |
6448 } | |
6449 | |
6450 DEFUN (__go_line__, args, , | |
6451 "-*- texinfo -*-\n\ | |
6452 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ | |
6945 | 6453 Undocumented internal function.\n\ |
6406 | 6454 @end deftypefn") |
6455 { | |
6456 GO_BODY (line); | |
6457 } | |
6458 | |
6459 DEFUN (__go_text__, args, , | |
6460 "-*- texinfo -*-\n\ | |
6461 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ | |
6945 | 6462 Undocumented internal function.\n\ |
6406 | 6463 @end deftypefn") |
6464 { | |
6465 GO_BODY (text); | |
6466 } | |
6467 | |
6468 DEFUN (__go_image__, args, , | |
6469 "-*- texinfo -*-\n\ | |
6470 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ | |
6945 | 6471 Undocumented internal function.\n\ |
6406 | 6472 @end deftypefn") |
6473 { | |
6474 GO_BODY (image); | |
6475 } | |
6476 | |
6477 DEFUN (__go_surface__, args, , | |
6478 "-*- texinfo -*-\n\ | |
6479 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ | |
6945 | 6480 Undocumented internal function.\n\ |
6406 | 6481 @end deftypefn") |
6482 { | |
6483 GO_BODY (surface); | |
6484 } | |
6485 | |
6807 | 6486 DEFUN (__go_patch__, args, , |
6487 "-*- texinfo -*-\n\ | |
6488 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ | |
6945 | 6489 Undocumented internal function.\n\ |
6807 | 6490 @end deftypefn") |
6491 { | |
6492 GO_BODY (patch); | |
6493 } | |
6494 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6495 DEFUN (__go_hggroup__, args, , |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6496 "-*- texinfo -*-\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6497 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6498 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6499 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6500 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6501 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6502 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6503 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6504 DEFUN (__go_uimenu__, args, , |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6505 "-*- texinfo -*-\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6506 @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
|
6507 Undocumented internal function.\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6508 @end deftypefn") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6509 { |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6510 GO_BODY (uimenu); |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6511 } |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6512 |
6406 | 6513 DEFUN (__go_delete__, args, , |
6514 "-*- texinfo -*-\n\ | |
6515 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ | |
6945 | 6516 Undocumented internal function.\n\ |
6406 | 6517 @end deftypefn") |
6518 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6519 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6520 |
6406 | 6521 octave_value_list retval; |
6522 | |
6523 if (args.length () == 1) | |
6524 { | |
6525 graphics_handle h = octave_NaN; | |
6526 | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
6527 const NDArray vals = args (0).array_value (); |
6406 | 6528 |
6529 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6530 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6531 // 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
|
6532 // 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
|
6533 // later want to delete |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6534 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
|
6535 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6536 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6537 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6538 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6539 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6540 error ("delete: invalid graphics object (= %g)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6541 vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6542 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6543 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6544 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6545 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6546 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6547 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6548 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
|
6549 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6550 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6551 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6552 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6553 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6554 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6555 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6556 // Don't do recursive deleting, due to callbacks |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6557 if (! obj.get_properties ().is_beingdeleted ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6558 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6559 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6560 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6561 graphics_object parent_obj = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6562 gh_manager::get_object (parent_h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6563 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6564 // NOTE: free the handle before removing it from its |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6565 // parent's children, such that the object's |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6566 // state is correct when the deletefcn callback |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6567 // is executed |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6568 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6569 gh_manager::free (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6570 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6571 // A callback function might have already deleted |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6572 // the parent |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6573 if (parent_obj.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6574 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6575 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6576 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6577 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6578 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6579 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6580 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6581 } |
6406 | 6582 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6583 error ("delete: invalid graphics object"); |
6406 | 6584 } |
6585 else | |
6586 print_usage (); | |
6587 | |
6588 return retval; | |
6589 } | |
6590 | |
6591 DEFUN (__go_axes_init__, args, , | |
6592 "-*- texinfo -*-\n\ | |
6593 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ | |
6945 | 6594 Undocumented internal function.\n\ |
6406 | 6595 @end deftypefn") |
6596 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6597 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6598 |
6406 | 6599 octave_value retval; |
6600 | |
6601 int nargin = args.length (); | |
6602 | |
6603 std::string mode = ""; | |
6604 | |
6605 if (nargin == 2) | |
6606 { | |
6607 mode = args(1).string_value (); | |
6608 | |
6609 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6610 return retval; |
6406 | 6611 } |
6612 | |
6613 if (nargin == 1 || nargin == 2) | |
6614 { | |
6615 graphics_handle h = octave_NaN; | |
6616 | |
6617 double val = args(0).double_value (); | |
6618 | |
6619 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6620 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6621 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6622 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6623 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6624 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6625 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6626 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6627 obj.set_defaults (mode); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6628 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6629 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6630 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6631 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
|
6632 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6633 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6634 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
|
6635 } |
6406 | 6636 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6637 error ("__go_axes_init__: invalid graphics object"); |
6406 | 6638 } |
6639 else | |
6640 print_usage (); | |
6641 | |
6642 return retval; | |
6643 } | |
6644 | |
6645 DEFUN (__go_handles__, , , | |
6646 "-*- texinfo -*-\n\ | |
6647 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ | |
6945 | 6648 Undocumented internal function.\n\ |
6406 | 6649 @end deftypefn") |
6650 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6651 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6652 |
6425 | 6653 return octave_value (gh_manager::handle_list ()); |
6654 } | |
6655 | |
6656 DEFUN (__go_figure_handles__, , , | |
6657 "-*- texinfo -*-\n\ | |
6658 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ | |
6945 | 6659 Undocumented internal function.\n\ |
6425 | 6660 @end deftypefn") |
6661 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6662 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6663 |
6425 | 6664 return octave_value (gh_manager::figure_handle_list ()); |
6406 | 6665 } |
6666 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6667 DEFUN (__go_execute_callback__, args, , |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6668 "-*- texinfo -*-\n\ |
10840 | 6669 @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
|
6670 @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
|
6671 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6672 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6673 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6674 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6675 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6676 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6677 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6678 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6679 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6680 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6681 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6682 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6683 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6684 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6685 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6686 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6687 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6688 std::string name = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6689 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6690 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6691 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6692 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6693 gh_manager::execute_callback (h, name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6694 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6695 gh_manager::execute_callback (h, name, args(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6696 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6697 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6698 error ("__go_execute_callback__: invalid callback name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6699 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6700 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6701 error ("__go_execute_callback__: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6702 val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6703 } |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6704 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6705 error ("__go_execute_callback__: invalid graphics object"); |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6706 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6707 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6708 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6709 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6710 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6711 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6712 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6713 DEFUN (__image_pixel_size__, args, , |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6714 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
6715 @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
|
6716 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
|
6717 @end deftypefn") |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6718 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6719 octave_value retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6720 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6721 int nargin = args.length (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6722 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6723 if (nargin == 1) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6724 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6725 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
|
6726 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6727 if (! error_state) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6728 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6729 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
|
6730 if (fobj && fobj.isa ("image")) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6731 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6732 image::properties& ip = |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6733 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
|
6734 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6735 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
|
6736 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
|
6737 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
|
6738 retval = dp; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6739 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6740 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6741 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
|
6742 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6743 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6744 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
|
6745 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6746 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6747 print_usage (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6748 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6749 return retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6750 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6751 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6752 DEFUN (available_graphics_toolkits, , , |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6753 "-*- texinfo -*-\n\ |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6754 @deftypefn {Built-in Function} {} available_graphiscs_toolkits ()\n\ |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6755 Return a cell array of registered graphics toolkits.\n\ |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6756 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6757 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6758 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6759 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6760 return octave_value (graphics_toolkit::available_toolkits_list ()); |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6761 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6762 |
7408 | 6763 DEFUN (drawnow, args, , |
6764 "-*- texinfo -*-\n\ | |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6765 @deftypefn {Built-in Function} {} drawnow ()\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6766 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6767 @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
|
6768 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
|
6769 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
|
6770 @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
|
6771 callbacks are processed.\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6772 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
|
6773 undocumented.\n\ |
7408 | 6774 @end deftypefn") |
6775 { | |
6776 static int drawnow_executing = 0; | |
6777 static bool __go_close_all_registered__ = false; | |
6778 | |
6779 octave_value retval; | |
6780 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6781 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6782 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6783 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6784 frame.protect_var (Vdrawnow_requested, false); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6785 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6786 frame.protect_var (drawnow_executing); |
7409 | 6787 |
6788 if (++drawnow_executing <= 1) | |
7408 | 6789 { |
7409 | 6790 if (! __go_close_all_registered__) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6791 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6792 octave_add_atexit_function ("__go_close_all__"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6793 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6794 __go_close_all_registered__ = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6795 } |
7409 | 6796 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6797 if (args.length () == 0 || args.length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6798 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6799 Matrix hlist = gh_manager::figure_handle_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6800 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6801 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
|
6802 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6803 graphics_handle h = gh_manager::lookup (hlist(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6804 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6805 if (h.ok () && h != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6806 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6807 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6808 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
|
6809 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6810 if (fprops.is_modified ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6811 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6812 if (fprops.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6813 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6814 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6815 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6816 fprops.get_toolkit ().redraw_figure (go); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6817 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6818 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6819 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6820 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6821 fprops.set_modified (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6822 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6823 } |
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 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6826 bool do_events = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6827 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6828 if (args.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6829 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6830 caseless_str val (args(0).string_value ()); |
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 if (! error_state && val.compare ("expose")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6833 do_events = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6834 else |
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 error ("drawnow: invalid argument, expected `expose' as argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6837 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6838 } |
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 if (do_events) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6842 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6843 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6844 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6845 gh_manager::process_events (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6846 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6847 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6848 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6849 } |
7409 | 6850 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
|
6851 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6852 std::string term, file, debug_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6853 bool mono; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6854 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6855 term = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6856 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6857 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6858 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6859 file = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6860 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6861 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6862 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6863 size_t pos = file.find_last_of (file_ops::dir_sep_chars ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6864 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6865 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6866 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6867 std::string dirname = file.substr (0, pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6868 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6869 file_stat fs (dirname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6870 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6871 if (! (fs && fs.is_dir ())) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6872 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6873 error ("drawnow: nonexistent directory `%s'", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6874 dirname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6875 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6876 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6877 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6878 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6879 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6880 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
|
6881 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6882 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6883 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6884 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
|
6885 : ""); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6886 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6887 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6888 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6889 graphics_handle h = gcf (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6890 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6891 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6892 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6893 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6894 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6895 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6896 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
6897 go.get_toolkit () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6898 .print_figure (go, term, file, mono, debug_file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6899 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6900 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6901 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6902 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6903 error ("drawnow: nothing to draw"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6904 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6905 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6906 error ("drawnow: invalid debug_file, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6907 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6908 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6909 error ("drawnow: invalid colormode, expected a boolean value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6910 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6911 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6912 error ("drawnow: invalid file, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6913 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6914 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6915 error ("drawnow: invalid terminal, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6916 } |
7408 | 6917 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6918 print_usage (); |
7408 | 6919 } |
7409 | 6920 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6921 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6922 |
7408 | 6923 return retval; |
6924 } | |
6925 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6926 DEFUN (addlistener, args, , |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6927 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6928 @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
|
6929 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
|
6930 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
|
6931 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
|
6932 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6933 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6934 @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
|
6935 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6936 @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
|
6937 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
|
6938 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
|
6939 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
|
6940 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
|
6941 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
|
6942 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
|
6943 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
|
6944 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6945 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6946 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6947 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6948 @group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6949 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
|
6950 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
|
6951 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6952 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6953 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
|
6954 @end group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6955 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6956 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6957 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6958 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6959 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6960 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6961 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6962 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6963 if (args.length () == 3) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6964 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6965 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6966 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6967 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6968 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6969 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6970 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6971 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6972 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6973 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6974 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6975 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6976 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6977 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6978 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6979 go.add_property_listener (pname, args(2), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6980 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6981 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6982 error ("addlistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6983 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6984 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6985 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6986 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
|
6987 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6988 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6989 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6990 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6991 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6992 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6993 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6994 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6995 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6996 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6997 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
|
6998 "-*- texinfo -*-\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6999 @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
|
7000 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
|
7001 @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
|
7002 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
|
7003 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
|
7004 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7005 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
|
7006 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
|
7007 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7008 Example:\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7009 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7010 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
7011 @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
|
7012 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
|
7013 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
|
7014 endfunction\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7015 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7016 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
|
7017 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
|
7018 dellistener (gcf, \"position\", c);\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
7019 @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
|
7020 @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
|
7021 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7022 @end deftypefn") |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7023 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7024 gh_manager::autolock guard; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7025 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7026 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
|
7027 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7028 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
|
7029 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7030 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
|
7031 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7032 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7033 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7034 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7035 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7036 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7037 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7038 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7039 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7040 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7041 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7042 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7043 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7044 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7045 go.delete_property_listener (pname, octave_value (), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7046 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7047 go.delete_property_listener (pname, args(2), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7048 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7049 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7050 error ("dellistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7051 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7052 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7053 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7054 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
|
7055 } |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7056 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7057 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
|
7058 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7059 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7060 print_usage (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7061 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7062 return retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7063 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
7064 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7065 DEFUN (addproperty, args, , |
7869 | 7066 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
7067 @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
|
7068 @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
|
7069 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
|
7070 @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
|
7071 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
|
7072 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
|
7073 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7074 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7075 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7076 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7077 @item string\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7078 A string property. @var{arg} contains the default string value.\n\ |
10840 | 7079 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7080 @item any\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7081 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
|
7082 value. @var{args} contains the default value.\n\ |
10840 | 7083 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7084 @item radio\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7085 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
|
7086 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
|
7087 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
|
7088 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
|
7089 an optional second string argument.\n\ |
10840 | 7090 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7091 @item boolean\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7092 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
|
7093 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
|
7094 the default property value.\n\ |
10840 | 7095 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7096 @item double\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7097 A scalar double property. @var{arg} contains the default value.\n\ |
10840 | 7098 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7099 @item handle\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7100 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
|
7101 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
|
7102 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
|
7103 the empty matrix.\n\ |
10840 | 7104 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7105 @item data\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7106 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
|
7107 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
|
7108 the empty matrix.\n\ |
10840 | 7109 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7110 @item color\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
7111 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
|
7112 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
|
7113 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
|
7114 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
|
7115 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7116 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7117 @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
|
7118 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
|
7119 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
|
7120 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
|
7121 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7122 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7123 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7124 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7125 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
7126 @group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7127 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7128 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
|
7129 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
7130 @end group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7131 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7132 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7133 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7134 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7135 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7136 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7137 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7138 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7139 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7140 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7141 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7142 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7143 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7144 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7145 double h = args(1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7146 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7147 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7148 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7149 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7150 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7151 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7152 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7153 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7154 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7155 std::string type = args(2).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7156 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7157 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7158 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7159 if (! go.get_properties ().has_property (name)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7160 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7161 property p = property::create (name, gh, type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7162 args.splice (0, 3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7163 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7164 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7165 go.get_properties ().insert_property (name, p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7166 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7167 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7168 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
|
7169 name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7170 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7171 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7172 error ("addproperty: invalid property type, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7173 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7174 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7175 error ("addproperty: invalid graphics object (= %g)", h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7176 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7177 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7178 error ("addproperty: invalid handle value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7179 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7180 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7181 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
|
7182 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7183 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7184 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7185 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7186 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7187 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7188 |
6595 | 7189 octave_value |
7447 | 7190 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
|
7191 const std::string& func) |
6595 | 7192 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7193 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7194 |
6595 | 7195 graphics_object obj = gh_manager::get_object (handle); |
7196 octave_value retval; | |
7197 | |
7198 if (obj) | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
7199 retval = obj.get (caseless_str (property)); |
6595 | 7200 else |
7201 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
7202 | |
7203 return retval; | |
7204 } | |
7205 | |
7206 bool | |
7447 | 7207 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
|
7208 const octave_value& arg, const std::string& func) |
6595 | 7209 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7210 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7211 |
6595 | 7212 graphics_object obj = gh_manager::get_object (handle); |
7213 int ret = false; | |
7214 | |
7215 if (obj) | |
7216 { | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
7217 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
|
7218 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
7219 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7220 ret = true; |
6595 | 7221 } |
7222 else | |
7223 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
7224 | |
7225 return ret; | |
7226 } |