Mercurial > octave-nkf
annotate src/graphics.cc @ 8196:32e9e8103390
Allow arrays of graphic handles to F__go_delete__
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 08 Oct 2008 11:29:27 -0400 |
parents | 277218396978 |
children | f6ca8ff51818 |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
3 Copyright (C) 2007 John W. Eaton | |
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" |
43 #include "error.h" | |
6595 | 44 #include "graphics.h" |
7409 | 45 #include "input.h" |
6705 | 46 #include "ov.h" |
47 #include "oct-obj.h" | |
48 #include "oct-map.h" | |
49 #include "ov-fcn-handle.h" | |
50 #include "parse.h" | |
7409 | 51 #include "toplev.h" |
7222 | 52 #include "unwind-prot.h" |
6595 | 53 |
6406 | 54 static void |
55 gripe_set_invalid (const std::string& pname) | |
56 { | |
57 error ("set: invalid value for %s property", pname.c_str ()); | |
58 } | |
59 | |
7363 | 60 static Matrix |
61 jet_colormap (void) | |
62 { | |
63 Matrix cmap (64, 3, 0.0); | |
64 | |
65 for (octave_idx_type i = 0; i < 64; i++) | |
66 { | |
67 // This is the jet colormap. It would be nice to be able | |
68 // to feval the jet function but since there is a static | |
69 // property object that includes a colormap_property | |
70 // object, we need to initialize this before main is even | |
71 // called, so calling an interpreted function is not | |
72 // possible. | |
73 | |
74 double x = i / 63.0; | |
75 | |
76 if (x >= 3.0/8.0 && x < 5.0/8.0) | |
77 cmap(i,0) = 4.0 * x - 3.0/2.0; | |
78 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
79 cmap(i,0) = 1.0; | |
80 else if (x >= 7.0/8.0) | |
81 cmap(i,0) = -4.0 * x + 9.0/2.0; | |
82 | |
83 if (x >= 1.0/8.0 && x < 3.0/8.0) | |
84 cmap(i,1) = 4.0 * x - 1.0/2.0; | |
85 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
86 cmap(i,1) = 1.0; | |
87 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
88 cmap(i,1) = -4.0 * x + 7.0/2.0; | |
89 | |
90 if (x < 1.0/8.0) | |
91 cmap(i,2) = 4.0 * x + 1.0/2.0; | |
92 else if (x >= 1.0/8.0 && x < 3.0/8.0) | |
93 cmap(i,2) = 1.0; | |
94 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
95 cmap(i,2) = -4.0 * x + 5.0/2.0; | |
96 } | |
97 | |
98 return cmap; | |
99 } | |
100 | |
101 static Matrix | |
102 default_colororder (void) | |
103 { | |
104 Matrix retval (7, 3, 0.0); | |
105 | |
106 retval(0,2) = 1.0; | |
107 | |
108 retval(1,1) = 0.5; | |
109 | |
110 retval(2,0) = 1.0; | |
111 | |
112 retval(3,1) = 0.75; | |
113 retval(3,2) = 0.75; | |
114 | |
115 retval(4,0) = 0.75; | |
116 retval(4,2) = 0.75; | |
117 | |
118 retval(5,0) = 0.75; | |
119 retval(5,1) = 0.75; | |
120 | |
121 retval(6,0) = 0.25; | |
122 retval(6,1) = 0.25; | |
123 retval(6,2) = 0.25; | |
124 | |
125 return retval; | |
126 } | |
127 | |
128 static Matrix | |
129 default_lim (void) | |
130 { | |
131 Matrix m (1, 2, 0); | |
132 m(1) = 1; | |
133 return m; | |
134 } | |
135 | |
136 static Matrix | |
137 default_data (void) | |
138 { | |
139 Matrix retval (1, 2); | |
140 | |
141 retval(0) = 0; | |
142 retval(1) = 1; | |
143 | |
144 return retval; | |
145 } | |
146 | |
7427 | 147 static Matrix |
148 default_axes_position (void) | |
149 { | |
150 Matrix m (1, 4, 0.0); | |
151 m(0) = 0.13; | |
152 m(1) = 0.11; | |
153 m(2) = 0.775; | |
154 m(3) = 0.815; | |
155 return m; | |
156 } | |
157 | |
158 static Matrix | |
159 default_axes_outerposition (void) | |
160 { | |
161 Matrix m (1, 4, 0.0); | |
162 m(2) = m(3) = 1.0; | |
163 return m; | |
164 } | |
165 | |
7445 | 166 static Matrix |
167 default_figure_position (void) | |
168 { | |
169 Matrix m (1, 4, 0.0); | |
170 m(0) = 300; | |
171 m(1) = 200; | |
172 m(2) = 560; | |
173 m(3) = 420; | |
174 return m; | |
175 } | |
176 | |
7427 | 177 static Matrix |
178 convert_position (const Matrix& pos, const caseless_str& from_units, | |
179 const caseless_str& to_units, | |
180 const Matrix& parent_dim = Matrix (1, 2, 0.0), | |
181 const graphics_backend& backend = graphics_backend ()) | |
182 { | |
183 Matrix retval (1, 4); | |
184 double res = 0; | |
185 | |
186 if (from_units.compare ("pixels")) | |
187 retval = pos; | |
188 else if (from_units.compare ("normalized")) | |
189 { | |
190 retval(0) = pos(0) * parent_dim(0) + 1; | |
191 retval(1) = pos(1) * parent_dim(1) + 1; | |
192 retval(2) = pos(2) * parent_dim(0); | |
193 retval(3) = pos(3) * parent_dim(1); | |
194 } | |
195 else if (from_units.compare ("characters")) | |
196 { | |
197 // FIXME: implement this | |
198 } | |
199 else | |
200 { | |
201 res = backend.get_screen_resolution (); | |
202 | |
203 double f = 0.0; | |
204 | |
205 if (from_units.compare ("points")) | |
206 f = res / 72.0; | |
207 else if (from_units.compare ("inches")) | |
208 f = res; | |
209 else if (from_units.compare ("centimeters")) | |
210 f = res / 2.54; | |
211 | |
212 if (f > 0) | |
213 { | |
214 retval(0) = pos(0) * f + 1; | |
215 retval(1) = pos(1) * f + 1; | |
216 retval(2) = pos(2) * f; | |
217 retval(3) = pos(3) * f; | |
218 } | |
219 } | |
220 | |
221 if (! to_units.compare ("pixels")) | |
222 { | |
223 if (to_units.compare ("normalized")) | |
224 { | |
225 retval(0) = (retval(0) - 1) / parent_dim(0); | |
226 retval(1) = (retval(1) - 1) / parent_dim(1); | |
227 retval(2) /= parent_dim(0); | |
228 retval(3) /= parent_dim(1); | |
229 } | |
230 else if (to_units.compare ("characters")) | |
231 { | |
232 // FIXME: implement this | |
233 } | |
234 else | |
235 { | |
236 if (res <= 0) | |
237 res = backend.get_screen_resolution (); | |
238 | |
239 double f = 0.0; | |
240 | |
241 if (to_units.compare ("points")) | |
242 f = res / 72.0; | |
243 else if (to_units.compare ("inches")) | |
244 f = res; | |
245 else if (to_units.compare ("centimeters")) | |
246 f = res / 2.54; | |
247 | |
248 if (f > 0) | |
249 { | |
250 retval(0) = (retval(0) - 1) / f; | |
251 retval(1) = (retval(1) - 1) / f; | |
252 retval(2) /= f; | |
253 retval(3) /= f; | |
254 } | |
255 } | |
256 } | |
257 | |
258 return retval; | |
259 } | |
260 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
261 static graphics_object |
7878
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
262 xget_ancestor (const graphics_object& go_arg, const std::string& type) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
263 { |
7878
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
264 graphics_object go = go_arg; |
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
265 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
266 do |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
267 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
268 if (go.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
269 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
270 if (go.isa (type)) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
271 return go; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
272 else |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
273 go = gh_manager::get_object (go.get_parent ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
274 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
275 else |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
276 return graphics_object (); |
7869 | 277 } |
278 while (true); | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
279 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
280 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
281 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
282 convert_cdata (const base_properties& props, const octave_value& cdata, |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
283 bool is_scaled, int cdim) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
284 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
285 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
|
286 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
287 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
|
288 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
289 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
290 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
|
291 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
|
292 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
293 graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
294 graphics_object fig = xget_ancestor (go, "figure"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
295 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
296 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
297 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
298 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
|
299 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
300 if (! error_state) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
301 cmap = _cmap; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
302 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
303 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
304 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
305 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
306 graphics_object ax = xget_ancestor (go, "axes"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
307 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
308 if (ax.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
309 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
310 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
311 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
312 if (! error_state) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
313 clim = _clim; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
314 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
315 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
316 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
317 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
318 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
319 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
320 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
321 |
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
|
322 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
|
323 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
|
324 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
325 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
|
326 const double *cmapv = cmap.data (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
327 const double *cv = 0; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
328 const octave_uint8 *icv = 0; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
329 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
330 if (cdata.is_integer_type ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
331 icv = cdata.uint8_array_value ().data (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
332 else |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
333 cv = cdata.array_value ().data (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
334 |
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
|
335 for (octave_idx_type i = 0; i < lda; i++) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
336 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
337 double x = (cv ? cv[i] : double (icv[i])); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
338 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
339 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
340 x = xround ((nc - 1) * (x - clim(0)) / (clim(1) - clim(0))); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
341 else |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
342 x = xround (x - 1); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
343 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
344 if (x < 0) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
345 x = 0; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
346 else if (x >= nc) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
347 x = (nc - 1); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
348 |
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
|
349 octave_idx_type idx = static_cast<octave_idx_type> (x); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
350 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
351 av[i] = cmapv[idx]; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
352 av[i+lda] = cmapv[idx+nc]; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
353 av[i+2*lda] = cmapv[idx+2*nc]; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
354 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
355 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
356 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
357 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
358 |
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
|
359 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
|
360 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
|
361 get_array_limits (const Array<T>& m, double& emin, double& emax, |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
362 double& eminp) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
363 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
364 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
|
365 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
|
366 |
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
|
367 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
|
368 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
369 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
|
370 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
371 if (! (xisinf (e) || xisnan (e))) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
372 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
373 if (e < emin) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
374 emin = e; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
375 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
376 if (e > emax) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
377 emax = e; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
378 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
379 if (e >= 0 && e < eminp) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
380 eminp = e; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
381 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
382 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
383 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
384 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
385 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
386 lookup_object_name (const caseless_str& name, caseless_str& go_name, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
387 caseless_str& rest) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
388 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
389 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
390 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
391 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
392 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
393 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
394 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
395 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
396 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
397 if (pfx.compare ("axes") || pfx.compare ("line") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
398 || pfx.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
399 offset = 4; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
400 else if (len >= 5) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
401 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
402 pfx = name.substr (0, 5); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
403 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
404 if (pfx.compare ("image") || pfx.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
405 offset = 5; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
406 else if (len >= 6) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
407 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
408 pfx = name.substr (0, 6); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
409 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
410 if (pfx.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
411 offset = 6; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
412 else if (len >= 7) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
413 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
414 pfx = name.substr (0, 7); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
415 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
416 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
417 offset = 7; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
418 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
419 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
420 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
421 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
422 if (offset > 0) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
423 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
424 go_name = pfx; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
425 rest = name.substr (offset); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
426 result = true; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
427 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
428 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
429 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
430 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
431 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
432 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
433 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
434 make_graphics_object_from_type (const caseless_str& type, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
435 const graphics_handle& h = graphics_handle (), |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
436 const graphics_handle& p = graphics_handle ()) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
437 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
438 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
439 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
440 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
441 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
442 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
443 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
444 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
445 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
446 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
447 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
448 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
449 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
450 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
451 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
452 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
453 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
454 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
455 go = new hggroup (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
456 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
457 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
458 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
459 |
6406 | 460 // --------------------------------------------------------------------- |
461 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
462 bool |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
463 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
|
464 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
465 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
466 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
467 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
468 // notify backend |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
469 if (id >= 0) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
470 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
471 graphics_object go = gh_manager::get_object (parent); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
472 if (go) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
473 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
474 graphics_backend backend = go.get_backend(); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
475 if (backend) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
476 backend.property_changed (go, id); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
477 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
478 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
479 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
480 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
481 if (do_run && ! error_state) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
482 run_listeners (POSTSET); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
483 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
484 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
485 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
486 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
487 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
488 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
489 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
490 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
491 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
492 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
|
493 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
494 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
|
495 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
496 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
|
497 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
498 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
|
499 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
500 if (error_state) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
501 break; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
502 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
503 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
504 |
6705 | 505 radio_values::radio_values (const std::string& opt_string) |
6406 | 506 { |
6705 | 507 size_t beg = 0; |
508 size_t len = opt_string.length (); | |
509 bool done = len == 0; | |
6681 | 510 |
6705 | 511 while (! done) |
512 { | |
513 size_t end = opt_string.find ('|', beg); | |
6681 | 514 |
6705 | 515 if (end == std::string::npos) |
516 { | |
517 end = len; | |
518 done = true; | |
519 } | |
6681 | 520 |
6705 | 521 std::string t = opt_string.substr (beg, end-beg); |
6681 | 522 |
6705 | 523 // Might want more error checking here... |
524 if (t[0] == '{') | |
525 { | |
526 t = t.substr (1, t.length () - 2); | |
527 default_val = t; | |
528 } | |
529 else if (beg == 0) // ensure default value | |
530 default_val = t; | |
6681 | 531 |
6705 | 532 possible_vals.insert (t); |
6681 | 533 |
6705 | 534 beg = end + 1; |
535 } | |
536 } | |
6681 | 537 |
6705 | 538 bool |
6761 | 539 color_values::str2rgb (std::string str) |
6681 | 540 { |
6705 | 541 double tmp_rgb[3] = {0, 0, 0}; |
542 bool retval = true; | |
6761 | 543 unsigned int len = str.length(); |
6681 | 544 |
6925 | 545 std::transform (str.begin (), str.end (), str.begin (), tolower); |
546 | |
6761 | 547 if (str.compare(0, len, "blue", 0, len) == 0) |
548 tmp_rgb[2] = 1; | |
7869 | 549 else if (str.compare(0, len, "black", 0, len) == 0 |
550 || str.compare(0, len, "k", 0, len) == 0) | |
6761 | 551 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
552 else if (str.compare(0, len, "red", 0, len) == 0) | |
553 tmp_rgb[0] = 1; | |
554 else if (str.compare(0, len, "green", 0, len) == 0) | |
555 tmp_rgb[1] = 1; | |
556 else if (str.compare(0, len, "yellow", 0, len) == 0) | |
557 tmp_rgb[0] = tmp_rgb[1] = 1; | |
558 else if (str.compare(0, len, "magenta", 0, len) == 0) | |
559 tmp_rgb[0] = tmp_rgb[2] = 1; | |
560 else if (str.compare(0, len, "cyan", 0, len) == 0) | |
561 tmp_rgb[1] = tmp_rgb[2] = 1; | |
7869 | 562 else if (str.compare(0, len, "white", 0, len) == 0 |
563 || str.compare(0, len, "w", 0, len) == 0) | |
6761 | 564 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; |
565 else | |
566 retval = false; | |
6406 | 567 |
6705 | 568 if (retval) |
569 { | |
570 for (int i = 0; i < 3; i++) | |
7363 | 571 xrgb(i) = tmp_rgb[i]; |
6705 | 572 } |
6563 | 573 |
6705 | 574 return retval; |
575 } | |
6681 | 576 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
577 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
578 color_property::do_set (const octave_value& val) |
6790 | 579 { |
580 if (val.is_string ()) | |
581 { | |
582 std::string s = val.string_value (); | |
583 | |
584 if (! s.empty ()) | |
585 { | |
6898 | 586 if (radio_val.contains (s)) |
6790 | 587 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
588 if (current_type != radio_t || current_val != s) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
589 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
590 current_val = s; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
591 current_type = radio_t; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
592 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
593 } |
6790 | 594 } |
595 else | |
596 { | |
597 color_values col (s); | |
598 if (! error_state) | |
599 { | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
600 if (current_type != color_t || col != color_val) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
601 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
602 color_val = col; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
603 current_type = color_t; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
604 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
605 } |
6790 | 606 } |
607 else | |
7363 | 608 error ("invalid value for color property \"%s\" (value = %s)", |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
609 get_name ().c_str (), s.c_str ()); |
6790 | 610 } |
611 } | |
612 else | |
7363 | 613 error ("invalid value for color property \"%s\"", |
614 get_name ().c_str ()); | |
6790 | 615 } |
616 else if (val.is_real_matrix ()) | |
617 { | |
618 Matrix m = val.matrix_value (); | |
619 | |
620 if (m.numel () == 3) | |
621 { | |
622 color_values col (m (0), m (1), m(2)); | |
623 if (! error_state) | |
624 { | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
625 if (current_type != color_t || col != color_val) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
626 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
627 color_val = col; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
628 current_type = color_t; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
629 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
630 } |
6790 | 631 } |
632 } | |
633 else | |
7363 | 634 error ("invalid value for color property \"%s\"", |
635 get_name ().c_str ()); | |
6790 | 636 } |
637 else | |
7363 | 638 error ("invalid value for color property \"%s\"", |
639 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
640 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
641 return false; |
6790 | 642 } |
643 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
644 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
645 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
|
646 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
647 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
648 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
649 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
|
650 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
651 if (! s.empty () && radio_val.contains (s)) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
652 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
653 if (current_type != radio_t || s != current_val) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
654 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
655 current_val = s; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
656 current_type = radio_t; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
657 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
658 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
659 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
660 else |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
661 error ("invalid value for double_radio property \"%s\"", |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
662 get_name ().c_str ()); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
663 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
664 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
|
665 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
666 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
667 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
668 if (current_type != double_t || new_dval != dval) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
669 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
670 dval = new_dval; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
671 current_type = double_t; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
672 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
673 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
674 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
675 else |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
676 error ("invalid value for double_radio property \"%s\"", |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
677 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
678 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
679 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
680 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
681 |
7363 | 682 bool |
683 array_property::validate (const octave_value& v) | |
684 { | |
7364 | 685 bool xok = false; |
7363 | 686 |
687 // FIXME: should we always support []? | |
688 if (v.is_empty () && v.is_double_type ()) | |
689 return true; | |
690 | |
691 // check value type | |
692 if (type_constraints.size () > 0) | |
693 { | |
694 for (std::list<std::string>::const_iterator it = type_constraints.begin (); | |
7364 | 695 ! 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
|
696 if ((*it) == v.class_name ()) |
7364 | 697 xok = true; |
7363 | 698 } |
699 else | |
7364 | 700 xok = v.is_double_type (); |
7363 | 701 |
7364 | 702 if (xok) |
7363 | 703 { |
704 dim_vector vdims = v.dims (); | |
705 int vlen = vdims.length (); | |
706 | |
7364 | 707 xok = false; |
7363 | 708 |
709 // check value size | |
710 if (size_constraints.size () > 0) | |
711 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); | |
7364 | 712 ! xok && it != size_constraints.end (); ++it) |
7363 | 713 { |
714 dim_vector itdims = (*it); | |
715 | |
716 if (itdims.length () == vlen) | |
717 { | |
7364 | 718 xok = true; |
7363 | 719 |
7364 | 720 for (int i = 0; xok && i < vlen; i++) |
7363 | 721 if (itdims(i) >= 0 && itdims(i) != vdims(i)) |
7364 | 722 xok = false; |
7363 | 723 } |
724 } | |
725 else | |
726 return true; | |
727 } | |
728 | |
7364 | 729 return xok; |
7363 | 730 } |
731 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
732 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
733 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
734 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
735 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
736 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
737 if (data.dims () == v.dims ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
738 { |
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
|
739 |
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
|
740 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
741 { \ |
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
|
742 if (data.numel () == 1) \ |
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
|
743 return data.F ## scalar_value () == \ |
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
|
744 v.F ## scalar_value (); \ |
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
|
745 else \ |
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
|
746 { \ |
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
|
747 /* Keep copy of array_value to allow sparse/bool arrays */ \ |
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
|
748 /* that are converted, to not be deallocated early */ \ |
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
|
749 const A m1 = data.F ## array_value (); \ |
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
|
750 const T* d1 = m1.data (); \ |
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
|
751 const A m2 = v.F ## array_value (); \ |
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
|
752 const T* d2 = m2.data ();\ |
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
|
753 \ |
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
|
754 bool flag = true; \ |
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
|
755 \ |
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
|
756 for (int i = 0; flag && i < data.numel (); i++) \ |
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
|
757 if (d1[i] != d2[i]) \ |
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
|
758 flag = false; \ |
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
|
759 \ |
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
|
760 return flag; \ |
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
|
761 } \ |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
762 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
763 |
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
|
764 if (data.is_double_type() || data.is_bool_type ()) |
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
|
765 CHECK_ARRAY_EQUAL (double, , NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
766 else if (data.is_single_type ()) |
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
|
767 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
768 else if (data.is_int8_type ()) |
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
|
769 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
770 else if (data.is_int16_type ()) |
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
|
771 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
772 else if (data.is_int32_type ()) |
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
|
773 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
774 else if (data.is_int64_type ()) |
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
|
775 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
776 else if (data.is_uint8_type ()) |
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
|
777 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
778 else if (data.is_uint16_type ()) |
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
|
779 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
780 else if (data.is_uint32_type ()) |
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
|
781 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
782 else if (data.is_uint64_type ()) |
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
|
783 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
784 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
785 } |
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; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
788 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
789 |
7363 | 790 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
|
791 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
|
792 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
793 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
|
794 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
|
795 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
796 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
|
797 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
798 if (data.is_integer_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
799 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
800 if (data.is_int8_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
801 get_array_limits (data.int8_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
802 else if (data.is_uint8_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
803 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
804 else if (data.is_int16_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
805 get_array_limits (data.int16_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
806 else if (data.is_uint16_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
807 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
808 else if (data.is_int32_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
809 get_array_limits (data.int32_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
810 else if (data.is_uint32_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
811 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
812 else if (data.is_int64_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
813 get_array_limits (data.int64_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
814 else if (data.is_uint64_type ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
815 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
816 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
817 else |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
818 get_array_limits (data.array_value (), xmin, xmax, xminp); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
819 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
820 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
821 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
822 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
823 handle_property::do_set (const octave_value& v) |
7363 | 824 { |
825 double dv = v.double_value (); | |
826 | |
827 if (! error_state) | |
828 { | |
829 graphics_handle gh = gh_manager::lookup (dv); | |
830 | |
831 if (xisnan (gh.value ()) || gh.ok ()) | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
832 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
833 if (current_val != gh) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
834 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
835 current_val = gh; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
836 return true; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
837 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
838 } |
7363 | 839 else |
840 error ("set: invalid graphics handle (= %g) for property \"%s\"", | |
7869 | 841 dv, get_name ().c_str ()); |
7363 | 842 } |
843 else | |
844 error ("set: invalid graphics handle for property \"%s\"", | |
7869 | 845 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
846 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
847 return false; |
7363 | 848 } |
849 | |
850 bool | |
7367 | 851 callback_property::validate (const octave_value& v) const |
7363 | 852 { |
7367 | 853 // case 1: function handle |
854 // case 2: cell array with first element being a function handle | |
855 // case 3: string corresponding to known function name | |
856 // case 4: evaluatable string | |
857 // case 5: empty matrix | |
858 | |
859 if (v.is_function_handle ()) | |
860 return true; | |
861 else if (v.is_string ()) | |
862 // complete validation will be done at execution-time | |
863 return true; | |
864 else if (v.is_cell () && v.length () > 0 | |
865 && (v.rows() == 1 || v.columns () == 1) | |
866 && v.cell_value ()(0).is_function_handle ()) | |
867 return true; | |
868 else if (v.is_empty ()) | |
869 return true; | |
870 | |
871 return false; | |
7363 | 872 } |
873 | |
874 void | |
7367 | 875 callback_property::execute (const octave_value& data) const |
7363 | 876 { |
7367 | 877 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
|
878 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
|
879 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
880 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
881 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
882 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
883 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
|
884 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
885 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
886 property::create (const std::string& name, const graphics_handle& h, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
887 const caseless_str& type, const octave_value_list& args) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
888 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
889 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
890 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
891 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
892 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
893 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
|
894 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
895 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
896 retval = property (new string_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
897 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
898 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
899 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
900 octave_value val = |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
901 (args.length () > 0 ? args(0) : octave_value (Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
902 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
903 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
904 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
905 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
906 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
907 if (args.length () > 0) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
908 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
909 std::string vals = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
910 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
911 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
912 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
913 retval = property (new radio_property (name, h, vals)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
914 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
915 if (args.length () > 1) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
916 retval.set (args(1)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
917 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
918 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
919 error ("addproperty: invalid argument for radio property, expected a string value"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
920 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
921 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
922 error ("addproperty: missing possible values for radio property"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
923 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
924 else if (type.compare ("double")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
925 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
926 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
|
927 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
928 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
929 retval = property (new double_property (name, h, d)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
930 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
931 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
932 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
933 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
|
934 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
935 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
936 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
937 graphics_handle gh (hh); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
938 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
939 retval = property (new handle_property (name, h, gh)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
940 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
941 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
942 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
943 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
944 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
945 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
946 if (args.length () > 0) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
947 retval.set (args(0)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
948 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
949 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
950 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
951 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
952 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
953 if (args.length () > 0) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
954 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
955 retval.set (args(0)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
956 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
957 // FIXME: additional argument could define constraints |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
958 // but is this really useful...? |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
959 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
960 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
961 else if (type.compare ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
962 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
963 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
964 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
965 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
966 if (args.length () > 1) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
967 rv = radio_values (args(1).string_value ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
968 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
969 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
970 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
971 retval = property (new color_property (name, h, cv, rv)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
972 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
973 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
974 { |
7869 | 975 if (args.length () > 0 && ! args(0).is_empty ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
976 retval.set (args(0)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
977 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
978 retval.set (rv.default_value ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
979 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
980 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
981 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
982 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
983 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
984 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
985 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
986 if (lookup_object_name (type, go_name, go_rest)) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
987 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
988 graphics_object go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
989 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
990 std::map<caseless_str, graphics_object>::const_iterator it = |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
991 dprop_obj_map.find (go_name); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
992 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
993 if (it == dprop_obj_map.end ()) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
994 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
995 base_graphics_object *bgo = |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
996 make_graphics_object_from_type (go_name); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
997 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
998 if (bgo) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
999 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1000 go = graphics_object (bgo); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1001 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1002 dprop_obj_map[go_name] = go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1003 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1004 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1005 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1006 go = it->second; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1007 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1008 if (go.valid_object ()) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1009 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1010 property prop = go.get_properties ().get_property (go_rest); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1011 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1012 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1013 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1014 retval = prop.clone (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1015 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1016 retval.set_parent (h); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1017 retval.set_name (name); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1018 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1019 if (args.length () > 0) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1020 retval.set (args(0)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1021 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1022 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1023 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1024 error ("addproperty: invalid object type (= %s)", |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1025 go_name.c_str ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1026 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1027 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1028 error ("addproperty: unsupported type for dynamic property (= %s)", |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1029 type.c_str ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1030 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1031 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1032 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1033 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1034 |
7363 | 1035 // --------------------------------------------------------------------- |
6681 | 1036 |
6705 | 1037 void |
7189 | 1038 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1039 { |
6705 | 1040 size_t offset = 0; |
6681 | 1041 |
6705 | 1042 size_t len = name.length (); |
6681 | 1043 |
6705 | 1044 if (len > 4) |
1045 { | |
7189 | 1046 caseless_str pfx = name.substr (0, 4); |
6681 | 1047 |
6705 | 1048 if (pfx.compare ("axes") || pfx.compare ("line") |
1049 || pfx.compare ("text")) | |
1050 offset = 4; | |
1051 else if (len > 5) | |
1052 { | |
1053 pfx = name.substr (0, 5); | |
6681 | 1054 |
6807 | 1055 if (pfx.compare ("image") || pfx.compare ("patch")) |
6705 | 1056 offset = 5; |
1057 else if (len > 6) | |
1058 { | |
1059 pfx = name.substr (0, 6); | |
6681 | 1060 |
6705 | 1061 if (pfx.compare ("figure")) |
1062 offset = 6; | |
1063 else if (len > 7) | |
1064 { | |
1065 pfx = name.substr (0, 7); | |
6681 | 1066 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
1067 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
6705 | 1068 offset = 7; |
1069 } | |
1070 } | |
1071 } | |
6681 | 1072 |
6705 | 1073 if (offset > 0) |
1074 { | |
1075 // FIXME -- should we validate property names and values here? | |
6406 | 1076 |
6705 | 1077 std::string pname = name.substr (offset); |
6406 | 1078 |
6705 | 1079 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
1080 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); | |
6406 | 1081 |
6705 | 1082 bool remove = false; |
1083 if (val.is_string ()) | |
1084 { | |
7189 | 1085 caseless_str tval = val.string_value (); |
6406 | 1086 |
6705 | 1087 remove = tval.compare ("remove"); |
1088 } | |
6406 | 1089 |
6705 | 1090 pval_map_type& pval_map = plist_map[pfx]; |
6406 | 1091 |
6705 | 1092 if (remove) |
1093 { | |
1094 pval_map_iterator p = pval_map.find (pname); | |
6406 | 1095 |
6705 | 1096 if (p != pval_map.end ()) |
1097 pval_map.erase (p); | |
1098 } | |
1099 else | |
1100 pval_map[pname] = val; | |
1101 } | |
1102 } | |
6406 | 1103 |
6705 | 1104 if (offset == 0) |
1105 error ("invalid default property specification"); | |
1106 } | |
6406 | 1107 |
6705 | 1108 octave_value |
7189 | 1109 property_list::lookup (const caseless_str& name) const |
6705 | 1110 { |
1111 octave_value retval; | |
6406 | 1112 |
6705 | 1113 size_t offset = 0; |
6406 | 1114 |
6705 | 1115 size_t len = name.length (); |
6406 | 1116 |
6705 | 1117 if (len > 4) |
1118 { | |
7189 | 1119 caseless_str pfx = name.substr (0, 4); |
6406 | 1120 |
6705 | 1121 if (pfx.compare ("axes") || pfx.compare ("line") |
1122 || pfx.compare ("text")) | |
1123 offset = 4; | |
1124 else if (len > 5) | |
1125 { | |
1126 pfx = name.substr (0, 5); | |
6406 | 1127 |
6807 | 1128 if (pfx.compare ("image") || pfx.compare ("patch")) |
6705 | 1129 offset = 5; |
1130 else if (len > 6) | |
1131 { | |
1132 pfx = name.substr (0, 6); | |
6406 | 1133 |
6705 | 1134 if (pfx.compare ("figure")) |
1135 offset = 6; | |
1136 else if (len > 7) | |
1137 { | |
1138 pfx = name.substr (0, 7); | |
6406 | 1139 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
1140 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
6705 | 1141 offset = 7; |
1142 } | |
1143 } | |
1144 } | |
6406 | 1145 |
6705 | 1146 if (offset > 0) |
1147 { | |
1148 std::string pname = name.substr (offset); | |
6406 | 1149 |
6705 | 1150 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
1151 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); | |
6406 | 1152 |
6705 | 1153 plist_map_const_iterator p = find (pfx); |
6432 | 1154 |
6705 | 1155 if (p != end ()) |
1156 { | |
1157 const pval_map_type& pval_map = p->second; | |
6406 | 1158 |
6705 | 1159 pval_map_const_iterator q = pval_map.find (pname); |
6406 | 1160 |
6705 | 1161 if (q != pval_map.end ()) |
1162 retval = q->second; | |
1163 } | |
1164 } | |
1165 } | |
6406 | 1166 |
6705 | 1167 return retval; |
1168 } | |
6406 | 1169 |
6705 | 1170 Octave_map |
1171 property_list::as_struct (const std::string& prefix_arg) const | |
1172 { | |
1173 Octave_map m; | |
6406 | 1174 |
6705 | 1175 for (plist_map_const_iterator p = begin (); p != end (); p++) |
1176 { | |
1177 std::string prefix = prefix_arg + p->first; | |
6406 | 1178 |
6705 | 1179 const pval_map_type pval_map = p->second; |
6406 | 1180 |
6705 | 1181 for (pval_map_const_iterator q = pval_map.begin (); |
1182 q != pval_map.end (); | |
1183 q++) | |
1184 m.assign (prefix + q->first, q->second); | |
1185 } | |
6406 | 1186 |
6705 | 1187 return m; |
1188 } | |
6432 | 1189 |
6874 | 1190 graphics_handle::graphics_handle (const octave_value& a) |
1191 : val (octave_NaN) | |
1192 { | |
1193 if (a.is_empty ()) | |
1194 /* do nothing */; | |
1195 else | |
1196 { | |
1197 double tval = a.double_value (); | |
1198 | |
1199 if (! error_state) | |
1200 val = tval; | |
1201 else | |
1202 error ("invalid graphics handle"); | |
1203 } | |
1204 } | |
1205 | |
6705 | 1206 void |
1207 graphics_object::set (const octave_value_list& args) | |
1208 { | |
1209 int nargin = args.length (); | |
6406 | 1210 |
6705 | 1211 if (nargin == 0) |
1212 rep->defaults (); | |
1213 else if (nargin % 2 == 0) | |
1214 { | |
1215 for (int i = 0; i < nargin; i += 2) | |
1216 { | |
7189 | 1217 caseless_str name = args(i).string_value (); |
6406 | 1218 |
6705 | 1219 if (! error_state) |
1220 { | |
1221 octave_value val = args(i+1); | |
6406 | 1222 |
6705 | 1223 if (val.is_string ()) |
1224 { | |
7189 | 1225 caseless_str tval = val.string_value (); |
6406 | 1226 |
6705 | 1227 if (tval.compare ("default")) |
1228 val = get_default (name); | |
1229 else if (tval.compare ("factory")) | |
1230 val = get_factory_default (name); | |
1231 } | |
6406 | 1232 |
6705 | 1233 if (error_state) |
1234 break; | |
6406 | 1235 |
6705 | 1236 rep->set (name, val); |
1237 } | |
1238 else | |
1239 error ("set: expecting argument %d to be a property name", i); | |
1240 } | |
1241 } | |
1242 else | |
1243 error ("set: invalid number of arguments"); | |
1244 } | |
6406 | 1245 |
1246 | |
6705 | 1247 graphics_handle |
1248 gh_manager::get_handle (const std::string& go_name) | |
1249 { | |
1250 graphics_handle retval; | |
6406 | 1251 |
6705 | 1252 if (go_name == "figure") |
1253 { | |
1254 // We always want the lowest unused figure number. | |
6406 | 1255 |
6705 | 1256 retval = 1; |
6425 | 1257 |
6705 | 1258 while (handle_map.find (retval) != handle_map.end ()) |
1259 retval++; | |
1260 } | |
1261 else | |
1262 { | |
1263 free_list_iterator p = handle_free_list.begin (); | |
6406 | 1264 |
6705 | 1265 if (p != handle_free_list.end ()) |
1266 { | |
1267 retval = *p; | |
1268 handle_free_list.erase (p); | |
1269 } | |
1270 else | |
7286 | 1271 { |
1272 static double maxrand = RAND_MAX + 2.0; | |
1273 | |
1274 retval = graphics_handle (next_handle); | |
1275 | |
7304 | 1276 next_handle = ceil (next_handle) - 1.0 - (rand () + 1.0) / maxrand; |
7286 | 1277 } |
6705 | 1278 } |
6406 | 1279 |
6705 | 1280 return retval; |
1281 } | |
6406 | 1282 |
6705 | 1283 void |
1284 gh_manager::do_free (const graphics_handle& h) | |
1285 { | |
7056 | 1286 if (h.ok ()) |
6705 | 1287 { |
6874 | 1288 if (h.value () != 0) |
6705 | 1289 { |
6874 | 1290 iterator p = handle_map.find (h); |
1291 | |
1292 if (p != handle_map.end ()) | |
1293 { | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1294 // FIXME: should we explicitely free all children first? |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1295 // => call delete_children () ? |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1296 |
7403 | 1297 p->second.get_properties ().set_beingdeleted (true); |
1298 p->second.get_properties ().execute_deletefcn (); | |
7367 | 1299 |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1300 // notify backend |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1301 graphics_backend backend = p->second.get_backend (); |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1302 if (backend) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1303 backend.object_destroyed (p->second); |
8102 | 1304 // note - this will be valid only for first explicitly deleted object. |
1305 // All his children will have unknown backend then. | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
1306 |
6874 | 1307 handle_map.erase (p); |
1308 | |
1309 if (h.value () < 0) | |
1310 handle_free_list.insert (h); | |
1311 } | |
1312 else | |
1313 error ("graphics_handle::free: invalid object %g", h.value ()); | |
6705 | 1314 } |
1315 else | |
6874 | 1316 error ("graphics_handle::free: can't delete root figure"); |
6705 | 1317 } |
1318 } | |
6406 | 1319 |
1320 gh_manager *gh_manager::instance = 0; | |
1321 | |
1322 static void | |
7189 | 1323 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 1324 const octave_value& val) |
1325 { | |
1326 graphics_object obj = gh_manager::get_object (h); | |
1327 obj.set (name, val); | |
1328 } | |
1329 | |
1330 static void | |
1331 xset (const graphics_handle& h, const octave_value_list& args) | |
1332 { | |
1333 if (args.length () > 0) | |
1334 { | |
1335 graphics_object obj = gh_manager::get_object (h); | |
1336 obj.set (args); | |
1337 } | |
1338 } | |
1339 | |
1340 | |
1341 static octave_value | |
7189 | 1342 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 1343 { |
1344 graphics_object obj = gh_manager::get_object (h); | |
1345 return obj.get (name); | |
1346 } | |
1347 | |
1348 static graphics_handle | |
1349 reparent (const octave_value& ov, const std::string& who, | |
1350 const std::string& property, const graphics_handle& new_parent, | |
1351 bool adopt = true) | |
1352 { | |
1353 graphics_handle h = octave_NaN; | |
1354 | |
1355 double val = ov.double_value (); | |
1356 | |
1357 if (! error_state) | |
1358 { | |
1359 h = gh_manager::lookup (val); | |
1360 | |
7056 | 1361 if (h.ok ()) |
6406 | 1362 { |
1363 graphics_object obj = gh_manager::get_object (h); | |
1364 | |
1365 graphics_handle parent_h = obj.get_parent (); | |
1366 | |
1367 graphics_object parent_obj = gh_manager::get_object (parent_h); | |
1368 | |
1369 parent_obj.remove_child (h); | |
1370 | |
1371 if (adopt) | |
6874 | 1372 obj.set ("parent", new_parent.value ()); |
6406 | 1373 else |
1374 obj.reparent (new_parent); | |
1375 } | |
1376 else | |
1377 error ("%s: invalid graphics handle (= %g) for %s", | |
1378 who.c_str (), val, property.c_str ()); | |
1379 } | |
1380 else | |
1381 error ("%s: expecting %s to be a graphics handle", | |
1382 who.c_str (), property.c_str ()); | |
1383 | |
1384 return h; | |
1385 } | |
1386 | |
1387 // This function is NOT equivalent to the scripting language function gcf. | |
1388 graphics_handle | |
1389 gcf (void) | |
1390 { | |
1391 octave_value val = xget (0, "currentfigure"); | |
1392 | |
1393 return val.is_empty () ? octave_NaN : val.double_value (); | |
1394 } | |
1395 | |
1396 // This function is NOT equivalent to the scripting language function gca. | |
1397 graphics_handle | |
1398 gca (void) | |
1399 { | |
1400 octave_value val = xget (gcf (), "currentaxes"); | |
1401 | |
1402 return val.is_empty () ? octave_NaN : val.double_value (); | |
1403 } | |
1404 | |
1405 static void | |
1406 adopt (const graphics_handle& p, const graphics_handle& h) | |
1407 { | |
1408 graphics_object parent_obj = gh_manager::get_object (p); | |
1409 | |
1410 parent_obj.adopt (h); | |
1411 } | |
1412 | |
1413 static bool | |
7056 | 1414 is_handle (const graphics_handle& h) |
1415 { | |
1416 return h.ok (); | |
1417 } | |
1418 | |
1419 static bool | |
6406 | 1420 is_handle (double val) |
1421 { | |
6874 | 1422 graphics_handle h = gh_manager::lookup (val); |
1423 | |
1424 return h.ok (); | |
6406 | 1425 } |
1426 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1427 static octave_value |
6406 | 1428 is_handle (const octave_value& val) |
1429 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1430 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1431 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1432 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
|
1433 retval = true; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1434 else if (val.is_real_matrix ()) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1435 { |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1436 if (val.is_string ()) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1437 retval = boolNDArray (val.dims (), false); |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1438 else |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1439 { |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1440 const NDArray handles = val.array_value (); |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1441 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1442 if (! error_state) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1443 { |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1444 boolNDArray result (handles.dims ()); |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1445 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1446 for (octave_idx_type i = 0; i < handles.numel (); i++) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1447 result.xelem (i) = is_handle (handles (i)); |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1448 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1449 retval = result; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1450 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1451 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1452 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1453 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1454 return retval; |
6406 | 1455 } |
1456 | |
1457 static bool | |
1458 is_figure (double val) | |
1459 { | |
1460 graphics_object obj = gh_manager::get_object (val); | |
1461 | |
1462 return obj && obj.isa ("figure"); | |
1463 } | |
1464 | |
7370 | 1465 static void |
1466 xcreatefcn (const graphics_handle& h) | |
1467 { | |
1468 graphics_object obj = gh_manager::get_object (h); | |
1469 obj.get_properties ().execute_createfcn (); | |
1470 } | |
1471 | |
6406 | 1472 // --------------------------------------------------------------------- |
1473 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1474 void |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1475 base_graphics_backend::property_changed (const graphics_handle& h, int id) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1476 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1477 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1478 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1479 property_changed (go, id); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1480 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1481 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1482 void |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1483 base_graphics_backend::object_created (const graphics_handle& h) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1484 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1485 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1486 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1487 object_created (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1488 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1489 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1490 void |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1491 base_graphics_backend::object_destroyed (const graphics_handle& h) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1492 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1493 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1494 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1495 object_destroyed (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1496 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1497 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1498 |
6406 | 1499 static int |
1500 compare (const void *a_arg, const void *b_arg) | |
1501 { | |
1502 double a = *(static_cast<const double *> (a_arg)); | |
1503 double b = *(static_cast<const double *> (b_arg)); | |
1504 | |
1505 return a > b ? 1 : (a < b) ? -1 : 0; | |
1506 } | |
1507 | |
1508 static Matrix | |
1509 maybe_set_children (const Matrix& kids, const octave_value& val) | |
1510 { | |
1511 const Matrix new_kids = val.matrix_value (); | |
1512 | |
1513 bool ok = true; | |
1514 | |
1515 if (! error_state) | |
1516 { | |
1517 if (kids.numel () == new_kids.numel ()) | |
1518 { | |
1519 Matrix t1 = kids; | |
1520 Matrix t2 = new_kids; | |
1521 | |
1522 t1.qsort (compare); | |
1523 t2.qsort (compare); | |
1524 | |
1525 if (t1 != t2) | |
1526 ok = false; | |
1527 } else | |
1528 ok = false; | |
1529 | |
1530 if (! ok) | |
1531 error ("set: new children must be a permutation of existing children"); | |
1532 } | |
1533 else | |
1534 { | |
1535 ok = false; | |
1536 error ("set: expecting children to be array of graphics handles"); | |
1537 } | |
1538 | |
1539 return ok ? new_kids : kids; | |
1540 } | |
1541 | |
6705 | 1542 void |
1543 base_properties::set_from_list (base_graphics_object& obj, | |
1544 property_list& defaults) | |
6406 | 1545 { |
6705 | 1546 std::string go_name = graphics_object_name (); |
6406 | 1547 |
6705 | 1548 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 1549 |
6705 | 1550 if (p != defaults.end ()) |
1551 { | |
1552 const property_list::pval_map_type pval_map = p->second; | |
6406 | 1553 |
6705 | 1554 for (property_list::pval_map_const_iterator q = pval_map.begin (); |
1555 q != pval_map.end (); | |
1556 q++) | |
1557 { | |
1558 std::string pname = q->first; | |
6406 | 1559 |
6705 | 1560 obj.set (pname, q->second); |
6406 | 1561 |
6705 | 1562 if (error_state) |
1563 { | |
1564 error ("error setting default property %s", pname.c_str ()); | |
1565 break; | |
1566 } | |
1567 } | |
1568 } | |
1569 } | |
6406 | 1570 |
7363 | 1571 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1572 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 1573 { |
1574 octave_value retval; | |
1575 | |
8090 | 1576 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
|
1577 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1578 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1579 retval = it->second.get (); |
7363 | 1580 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1581 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 1582 |
1583 return retval; | |
1584 } | |
1585 | |
1586 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1587 base_properties::get_dynamic (bool all) const |
7363 | 1588 { |
1589 Octave_map m; | |
1590 | |
8090 | 1591 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin (); |
7363 | 1592 it != all_props.end (); ++it) |
7379 | 1593 if (all || ! it->second.is_hidden ()) |
1594 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 1595 |
1596 return m; | |
1597 } | |
1598 | |
1599 void | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1600 base_properties::set_dynamic (const caseless_str& name, const octave_value& val) |
7363 | 1601 { |
8090 | 1602 std::map<caseless_str, property, cmp_caseless_str>::iterator it = all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1603 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1604 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1605 it->second.set (val); |
7363 | 1606 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1607 error ("set: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1608 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1609 if (! error_state) |
7363 | 1610 mark_modified (); |
1611 } | |
1612 | |
1613 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1614 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 1615 { |
8090 | 1616 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
|
1617 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1618 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1619 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1620 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1621 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1622 } |
7363 | 1623 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1624 return it->second; |
7363 | 1625 } |
1626 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1627 bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1628 base_properties::has_property (const caseless_str& name) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1629 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1630 property p; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1631 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1632 unwind_protect::begin_frame("base_properties::has_property"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1633 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1634 unwind_protect_bool (discard_error_messages); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1635 unwind_protect_int (error_state); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1636 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1637 discard_error_messages = true; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1638 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1639 p = get_property (name); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1640 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1641 unwind_protect::run_frame ("base_properties::has_property"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1642 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1643 return (p.ok ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1644 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1645 |
6705 | 1646 void |
1647 base_properties::remove_child (const graphics_handle& h) | |
6406 | 1648 { |
6705 | 1649 octave_idx_type k = -1; |
1650 octave_idx_type n = children.numel (); | |
1651 for (octave_idx_type i = 0; i < n; i++) | |
6406 | 1652 { |
6874 | 1653 if (h.value () == children(i)) |
6406 | 1654 { |
6705 | 1655 k = i; |
1656 break; | |
6406 | 1657 } |
1658 } | |
1659 | |
6705 | 1660 if (k >= 0) |
6406 | 1661 { |
6705 | 1662 Matrix new_kids (1, n-1); |
1663 octave_idx_type j = 0; | |
1664 for (octave_idx_type i = 0; i < n; i++) | |
1665 { | |
1666 if (i != k) | |
1667 new_kids(j++) = children(i); | |
1668 } | |
1669 children = new_kids; | |
7378 | 1670 mark_modified (); |
6406 | 1671 } |
6705 | 1672 } |
6406 | 1673 |
6836 | 1674 void |
1675 base_properties::set_parent (const octave_value& val) | |
6705 | 1676 { |
1677 double tmp = val.double_value (); | |
6406 | 1678 |
6705 | 1679 graphics_handle new_parent = octave_NaN; |
6406 | 1680 |
6705 | 1681 if (! error_state) |
1682 { | |
1683 new_parent = gh_manager::lookup (tmp); | |
6406 | 1684 |
7056 | 1685 if (new_parent.ok ()) |
6705 | 1686 { |
7363 | 1687 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
6406 | 1688 |
6705 | 1689 parent_obj.remove_child (__myhandle__); |
6406 | 1690 |
7363 | 1691 parent = new_parent.as_octave_value (); |
6406 | 1692 |
7363 | 1693 ::adopt (parent.handle_value (), __myhandle__); |
6705 | 1694 } |
1695 else | |
1696 error ("set: invalid graphics handle (= %g) for parent", tmp); | |
1697 } | |
1698 else | |
1699 error ("set: expecting parent to be a graphics handle"); | |
1700 } | |
6432 | 1701 |
6705 | 1702 void |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1703 base_properties::set_children (const octave_value& val) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1704 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1705 children = maybe_set_children (children, val); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1706 } |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1707 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
1708 void |
6836 | 1709 base_properties::mark_modified (void) |
1710 { | |
7363 | 1711 __modified__ = "on"; |
1712 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 1713 if (parent_obj) |
1714 parent_obj.mark_modified (); | |
6836 | 1715 } |
1716 | |
1717 void | |
1718 base_properties::override_defaults (base_graphics_object& obj) | |
1719 { | |
7363 | 1720 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
|
1721 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1722 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1723 parent_obj.override_defaults (obj); |
6836 | 1724 } |
1725 | |
1726 void | |
7214 | 1727 base_properties::update_axis_limits (const std::string& axis_type) const |
1728 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1729 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
|
1730 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1731 if (obj) |
7214 | 1732 obj.update_axis_limits (axis_type); |
1733 } | |
1734 | |
1735 void | |
6836 | 1736 base_properties::delete_children (void) |
1737 { | |
1738 octave_idx_type n = children.numel (); | |
1739 | |
1740 for (octave_idx_type i = 0; i < n; i++) | |
8102 | 1741 gh_manager::free (children(i)); |
6836 | 1742 } |
1743 | |
7419 | 1744 graphics_backend |
1745 base_properties::get_backend (void) const | |
1746 { | |
1747 graphics_object go = gh_manager::get_object (get_parent ()); | |
1748 | |
1749 if (go) | |
1750 return go.get_backend (); | |
1751 else | |
1752 return graphics_backend (); | |
1753 } | |
1754 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1755 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1756 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
|
1757 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1758 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
|
1759 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1760 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
|
1761 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1762 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
|
1763 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1764 if (go.valid_object ()) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1765 go.get_properties ().update_boundingbox (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1766 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1767 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1768 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1769 void |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1770 base_properties::add_listener (const caseless_str& nm, const octave_value& v, |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1771 listener_mode mode) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1772 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1773 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1774 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1775 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1776 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1777 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1778 |
7363 | 1779 // --------------------------------------------------------------------- |
1780 | |
7408 | 1781 class gnuplot_backend : public base_graphics_backend |
1782 { | |
1783 public: | |
1784 gnuplot_backend (void) | |
1785 : base_graphics_backend ("gnuplot") { } | |
1786 | |
1787 ~gnuplot_backend (void) { } | |
1788 | |
1789 bool is_valid (void) const { return true; } | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1790 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1791 void object_destroyed (const graphics_object& go) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1792 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1793 if (go.isa ("figure")) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1794 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1795 const figure::properties& props = |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1796 dynamic_cast<const figure::properties&> (go.get_properties ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1797 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1798 send_quit (props.get___plot_stream__ ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1799 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1800 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1801 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1802 void property_changed (const graphics_object& go, int id) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1803 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1804 if (go.isa ("figure")) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1805 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1806 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1807 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1808 figure::properties& props = |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1809 dynamic_cast<figure::properties&> (obj.get_properties ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1810 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1811 switch (id) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1812 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1813 case base_properties::VISIBLE: |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1814 if (! props.is_visible ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1815 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1816 send_quit (props.get___plot_stream__ ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1817 props.set___plot_stream__ (Matrix ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1818 props.set___enhanced__ (false); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1819 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1820 break; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1821 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1822 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1823 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1824 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1825 void redraw_figure (const graphics_object& go) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1826 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1827 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1828 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1829 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1830 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1831 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1832 void print_figure (const graphics_object& go, const std::string& term, |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1833 const std::string& file, bool mono, |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1834 const std::string& debug_file) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1835 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1836 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1837 if (! debug_file.empty ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1838 args(4) = debug_file; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1839 args(3) = mono; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1840 args(2) = file; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1841 args(1) = term; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1842 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1843 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1844 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1845 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1846 Matrix get_canvas_size (const graphics_handle&) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1847 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1848 Matrix sz (1, 2, 0.0); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1849 return sz; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1850 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1851 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1852 double get_screen_resolution (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1853 { return 72.0; } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1854 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1855 Matrix get_screen_size (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1856 { return Matrix (1, 2, 0.0); } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1857 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1858 private: |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1859 void send_quit (const octave_value& pstream) const |
7408 | 1860 { |
1861 if (! pstream.is_empty()) | |
1862 { | |
1863 octave_value_list args; | |
7680
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1864 Matrix fids = pstream.matrix_value (); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1865 |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1866 if (! error_state) |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1867 { |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1868 args(1) = "\nquit;\n"; |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1869 args(0) = octave_value (fids (0)); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1870 feval ("fputs", args); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1871 args.resize (1); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1872 feval ("fflush", args); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1873 feval ("pclose", args); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1874 if (fids.numel () > 1) |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1875 { |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1876 args(0) = octave_value (fids (1)); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1877 feval ("pclose", args); |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1878 } |
a0ec02774303
Use popen2 for communication with gnuplot
David Bateman <dbateman@free.fr>
parents:
7527
diff
changeset
|
1879 } |
7408 | 1880 } |
1881 } | |
1882 }; | |
1883 | |
1884 graphics_backend | |
1885 graphics_backend::default_backend (void) | |
1886 { | |
1887 if (available_backends.size () == 0) | |
1888 register_backend (new gnuplot_backend ()); | |
1889 | |
1890 return available_backends["gnuplot"]; | |
1891 } | |
1892 | |
1893 std::map<std::string, graphics_backend> graphics_backend::available_backends; | |
1894 | |
1895 // --------------------------------------------------------------------- | |
1896 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1897 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1898 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
|
1899 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1900 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
|
1901 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1902 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
|
1903 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1904 if (parent_obj) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1905 parent_obj.update_axis_limits (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
|
1906 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1907 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1908 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
|
1909 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1910 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1911 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1912 |
7363 | 1913 #include "graphics-props.cc" |
1914 | |
1915 // --------------------------------------------------------------------- | |
1916 | |
6836 | 1917 void |
7363 | 1918 root_figure::properties::set_currentfigure (const octave_value& v) |
6874 | 1919 { |
7378 | 1920 graphics_handle val (v); |
7363 | 1921 |
6874 | 1922 if (error_state) |
1923 return; | |
1924 | |
7059 | 1925 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 1926 { |
1927 currentfigure = val; | |
1928 | |
7363 | 1929 gh_manager::push_figure (val); |
6874 | 1930 } |
1931 else | |
1932 gripe_set_invalid ("currentfigure"); | |
1933 } | |
1934 | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1935 void |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1936 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
|
1937 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1938 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1939 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1940 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1941 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1942 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1943 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1944 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1945 if (! cbo_stack.empty ()) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1946 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1947 val = cbo_stack.front (); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1948 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1949 cbo_stack.pop_front (); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1950 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1951 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1952 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1953 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1954 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1955 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1956 if (get_callbackobject ().ok ()) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1957 cbo_stack.push_front (get_callbackobject ()); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1958 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1959 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1960 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1961 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1962 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1963 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
1964 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1965 void |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1966 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
|
1967 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1968 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1969 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1970 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1971 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1972 xset (0, "currentfigure", cf.value ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1973 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1974 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1975 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
1976 |
6406 | 1977 property_list |
1978 root_figure::factory_properties = root_figure::init_factory_properties (); | |
1979 | |
1980 // --------------------------------------------------------------------- | |
1981 | |
7363 | 1982 void |
1983 figure::properties::set_currentaxes (const octave_value& v) | |
1984 { | |
7378 | 1985 graphics_handle val (v); |
6705 | 1986 |
6874 | 1987 if (error_state) |
1988 return; | |
1989 | |
7070 | 1990 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 1991 currentaxes = val; |
1992 else | |
1993 gripe_set_invalid ("currentaxes"); | |
1994 } | |
1995 | |
1996 void | |
1997 figure::properties::set_visible (const octave_value& val) | |
1998 { | |
1999 std::string s = val.string_value (); | |
2000 | |
2001 if (! error_state) | |
2002 { | |
2003 if (s == "on") | |
2004 xset (0, "currentfigure", __myhandle__.value ()); | |
2005 | |
2006 visible = val; | |
2007 } | |
2008 } | |
2009 | |
7445 | 2010 Matrix |
7447 | 2011 figure::properties::get_boundingbox (bool) const |
7445 | 2012 { |
2013 graphics_backend b = get_backend (); | |
2014 // FIXME: screen size should be obtained from root object | |
2015 Matrix screen_size = b.get_screen_size (); | |
2016 Matrix pos; | |
2017 | |
2018 pos = convert_position (get_position ().matrix_value (), get_units (), | |
2019 "pixels", screen_size, b); | |
2020 | |
2021 pos(0)--; | |
2022 pos(1)--; | |
7447 | 2023 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 2024 |
2025 return pos; | |
2026 } | |
2027 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2028 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2029 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
|
2030 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2031 graphics_backend b = get_backend (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2032 // FIXME: screen size should be obtained from root object |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2033 Matrix screen_size = b.get_screen_size (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2034 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
|
2035 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2036 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
|
2037 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
|
2038 pos(0)++; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2039 pos = convert_position (pos, "pixels", get_units (), screen_size, b); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2040 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2041 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
|
2042 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2043 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2044 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2045 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
|
2046 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2047 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
|
2048 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2049 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
|
2050 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2051 old_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
|
2052 position = v; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2053 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
|
2054 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2055 if (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
|
2056 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2057 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3)) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2058 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2059 execute_resizefcn (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2060 update_boundingbox (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2061 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2062 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2063 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2064 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
|
2065 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2066 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2067 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2068 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2069 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2070 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2071 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2072 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2073 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
2074 std::string nm = get_name (); |
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 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
|
2077 if (! nm.empty ()) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2078 os << ": " << get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2079 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2080 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2081 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2082 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2083 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2084 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2085 |
6836 | 2086 octave_value |
7189 | 2087 figure::get_default (const caseless_str& name) const |
6836 | 2088 { |
2089 octave_value retval = default_properties.lookup (name); | |
2090 | |
2091 if (retval.is_undefined ()) | |
2092 { | |
2093 graphics_handle parent = get_parent (); | |
2094 graphics_object parent_obj = gh_manager::get_object (parent); | |
2095 | |
2096 retval = parent_obj.get_default (name); | |
2097 } | |
2098 | |
2099 return retval; | |
2100 } | |
2101 | |
6406 | 2102 // --------------------------------------------------------------------- |
2103 | |
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
|
2104 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
|
2105 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
|
2106 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2107 // FIXME -- this should take font metrics into consideration, |
8102 | 2108 // for now we'll just make it position 90% of outerposition |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2109 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
|
2110 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2111 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
|
2112 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
|
2113 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
|
2114 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
|
2115 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
|
2116 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
|
2117 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
|
2118 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
|
2119 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2120 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
|
2121 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2122 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
|
2123 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
|
2124 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
|
2125 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
|
2126 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
|
2127 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
|
2128 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2129 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2130 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
|
2131 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2132 |
7363 | 2133 void |
2134 axes::properties::set_title (const octave_value& v) | |
6962 | 2135 { |
7363 | 2136 graphics_handle val = ::reparent (v, "set", "title", __myhandle__, false); |
6962 | 2137 |
6874 | 2138 if (! error_state) |
2139 { | |
7363 | 2140 gh_manager::free (title.handle_value ()); |
6874 | 2141 title = val; |
2142 } | |
2143 } | |
2144 | |
2145 void | |
7363 | 2146 axes::properties::set_xlabel (const octave_value& v) |
6874 | 2147 { |
7363 | 2148 graphics_handle val = ::reparent (v, "set", "xlabel", __myhandle__, false); |
6874 | 2149 |
2150 if (! error_state) | |
2151 { | |
7363 | 2152 gh_manager::free (xlabel.handle_value ()); |
6874 | 2153 xlabel = val; |
2154 } | |
2155 } | |
2156 | |
2157 void | |
7363 | 2158 axes::properties::set_ylabel (const octave_value& v) |
6874 | 2159 { |
7363 | 2160 graphics_handle val = ::reparent (v, "set", "ylabel", __myhandle__, false); |
6874 | 2161 |
2162 if (! error_state) | |
2163 { | |
7363 | 2164 gh_manager::free (ylabel.handle_value ()); |
6874 | 2165 ylabel = val; |
2166 } | |
2167 } | |
2168 | |
2169 void | |
7363 | 2170 axes::properties::set_zlabel (const octave_value& v) |
6874 | 2171 { |
7363 | 2172 graphics_handle val = ::reparent (v, "set", "zlabel", __myhandle__, false); |
6874 | 2173 |
2174 if (! error_state) | |
2175 { | |
7363 | 2176 gh_manager::free (zlabel.handle_value ()); |
6874 | 2177 zlabel = val; |
2178 } | |
2179 } | |
2180 | |
2181 void | |
6844 | 2182 axes::properties::set_defaults (base_graphics_object& obj, |
6890 | 2183 const std::string& mode) |
6705 | 2184 { |
7363 | 2185 title = graphics_handle (); |
6705 | 2186 box = "on"; |
2187 key = "off"; | |
2188 keybox = "off"; | |
7363 | 2189 keypos = 1.0; |
6962 | 2190 colororder = default_colororder (); |
6705 | 2191 dataaspectratio = Matrix (1, 3, 1.0); |
2192 dataaspectratiomode = "auto"; | |
7363 | 2193 layer = "bottom"; |
6705 | 2194 |
2195 Matrix tlim (1, 2, 0.0); | |
2196 tlim(1) = 1; | |
2197 xlim = tlim; | |
2198 ylim = tlim; | |
2199 zlim = tlim; | |
6807 | 2200 |
2201 Matrix cl (1, 2, 0); | |
2202 cl(1) = 1; | |
2203 clim = cl; | |
2204 | |
7363 | 2205 xlimmode = "auto"; |
2206 ylimmode = "auto"; | |
2207 zlimmode = "auto"; | |
2208 climmode = "auto"; | |
2209 xlabel = graphics_handle (); | |
2210 ylabel = graphics_handle (); | |
2211 zlabel = graphics_handle (); | |
6705 | 2212 xgrid = "off"; |
2213 ygrid = "off"; | |
2214 zgrid = "off"; | |
2215 xminorgrid = "off"; | |
2216 yminorgrid = "off"; | |
2217 zminorgrid = "off"; | |
2218 xtick = Matrix (); | |
2219 ytick = Matrix (); | |
2220 ztick = Matrix (); | |
2221 xtickmode = "auto"; | |
2222 ytickmode = "auto"; | |
2223 ztickmode = "auto"; | |
2224 xticklabel = ""; | |
2225 yticklabel = ""; | |
2226 zticklabel = ""; | |
2227 xticklabelmode = "auto"; | |
2228 yticklabelmode = "auto"; | |
2229 zticklabelmode = "auto"; | |
7453 | 2230 color = color_values (1, 1, 1); |
7364 | 2231 xcolor = color_values ("black"); |
2232 ycolor = color_values ("black"); | |
2233 zcolor = color_values ("black"); | |
7363 | 2234 xscale = "linear"; |
2235 yscale = "linear"; | |
2236 zscale = "linear"; | |
6705 | 2237 xdir = "normal"; |
2238 ydir = "normal"; | |
2239 zdir = "normal"; | |
7363 | 2240 yaxislocation = "left"; |
2241 xaxislocation = "bottom"; | |
6705 | 2242 |
7427 | 2243 // Note: camera properties will be set through update_transform |
2244 camerapositionmode = "auto"; | |
2245 cameratargetmode = "auto"; | |
2246 cameraupvectormode = "auto"; | |
2247 cameraviewanglemode = "auto"; | |
2248 plotboxaspectratio = Matrix (1, 3, 1.0); | |
2249 drawmode = "normal"; | |
2250 fontangle = "normal"; | |
2251 fontname = "Helvetica"; | |
2252 fontsize = 12; | |
2253 fontunits = "points"; | |
2254 fontweight = "normal"; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
2255 gridlinestyle = ":"; |
7427 | 2256 linestyleorder = "-"; |
2257 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
2258 minorgridlinestyle = ":"; |
7427 | 2259 // Note: plotboxaspectratio will be set through update_aspectratiors |
2260 plotboxaspectratiomode = "auto"; | |
2261 projection = "orthographic"; | |
2262 tickdir = "in"; | |
2263 tickdirmode = "auto"; | |
2264 ticklength = Matrix (1, 2, 0.1); | |
2265 tightinset = Matrix (1, 4, 0.0); | |
2266 | |
2267 sx = "linear"; | |
2268 sy = "linear"; | |
2269 sz = "linear"; | |
2270 | |
6705 | 2271 Matrix tview (1, 2, 0.0); |
2272 tview(1) = 90; | |
2273 view = tview; | |
2274 | |
6765 | 2275 visible = "on"; |
6705 | 2276 nextplot = "replace"; |
2277 | |
2278 // FIXME -- this is not quite right; we should preserve | |
2279 // "position" and "units". | |
2280 | |
2281 if (mode != "replace") | |
2282 { | |
6406 | 2283 Matrix touterposition (1, 4, 0.0); |
2284 touterposition(2) = 1; | |
2285 touterposition(3) = 1; | |
2286 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
|
2287 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
2288 position = default_axes_position (); |
6406 | 2289 } |
2290 | |
7363 | 2291 activepositionproperty = "outerposition"; |
8102 | 2292 __colorbar__ = "none"; |
7189 | 2293 |
6705 | 2294 delete_children (); |
6406 | 2295 |
6705 | 2296 children = Matrix (); |
6432 | 2297 |
7427 | 2298 update_transform (); |
2299 | |
6705 | 2300 override_defaults (obj); |
2301 } | |
2302 | |
6874 | 2303 graphics_handle |
2304 axes::properties::get_title (void) const | |
2305 { | |
7363 | 2306 if (! title.handle_value ().ok ()) |
6874 | 2307 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
2308 | |
7363 | 2309 return title.handle_value (); |
6874 | 2310 } |
2311 | |
2312 graphics_handle | |
2313 axes::properties::get_xlabel (void) const | |
2314 { | |
7363 | 2315 if (! xlabel.handle_value ().ok ()) |
6874 | 2316 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
2317 | |
7363 | 2318 return xlabel.handle_value (); |
6874 | 2319 } |
2320 | |
2321 graphics_handle | |
2322 axes::properties::get_ylabel (void) const | |
2323 { | |
7363 | 2324 if (! ylabel.handle_value ().ok ()) |
6874 | 2325 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
2326 | |
7363 | 2327 return ylabel.handle_value (); |
6874 | 2328 } |
2329 | |
2330 graphics_handle | |
2331 axes::properties::get_zlabel (void) const | |
2332 { | |
7363 | 2333 if (! zlabel.handle_value ().ok ()) |
6874 | 2334 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
2335 | |
7363 | 2336 return zlabel.handle_value (); |
6705 | 2337 } |
6406 | 2338 |
6705 | 2339 void |
6844 | 2340 axes::properties::remove_child (const graphics_handle& h) |
6705 | 2341 { |
7363 | 2342 if (title.handle_value ().ok () && h == title.handle_value ()) |
6705 | 2343 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
7363 | 2344 else if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
6705 | 2345 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
7363 | 2346 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
6705 | 2347 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
7363 | 2348 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
6705 | 2349 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
2350 else | |
2351 base_properties::remove_child (h); | |
2352 } | |
6406 | 2353 |
6705 | 2354 void |
6844 | 2355 axes::properties::delete_children (void) |
6705 | 2356 { |
2357 base_properties::delete_children (); | |
2358 | |
7363 | 2359 gh_manager::free (title.handle_value ()); |
2360 gh_manager::free (xlabel.handle_value ()); | |
2361 gh_manager::free (ylabel.handle_value ()); | |
2362 gh_manager::free (zlabel.handle_value ()); | |
6705 | 2363 } |
6406 | 2364 |
7427 | 2365 inline Matrix |
2366 xform_matrix (void) | |
2367 { | |
2368 Matrix m (4, 4, 0.0); | |
2369 for (int i = 0; i < 4; i++) | |
2370 m(i,i) = 1; | |
2371 return m; | |
2372 } | |
2373 | |
2374 inline ColumnVector | |
2375 xform_vector (void) | |
2376 { | |
2377 ColumnVector v (4, 0.0); | |
2378 v(3) = 1; | |
2379 return v; | |
2380 } | |
2381 | |
2382 inline ColumnVector | |
2383 xform_vector (double x, double y, double z) | |
2384 { | |
2385 ColumnVector v (4, 1.0); | |
2386 v(0) = x; v(1) = y; v(2) = z; | |
2387 return v; | |
2388 } | |
2389 | |
2390 inline ColumnVector | |
2391 transform (const Matrix& m, double x, double y, double z) | |
2392 { | |
2393 return (m * xform_vector (x, y, z)); | |
2394 } | |
2395 | |
2396 inline Matrix | |
2397 xform_scale (double x, double y, double z) | |
2398 { | |
2399 Matrix m (4, 4, 0.0); | |
2400 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
2401 return m; | |
2402 } | |
2403 | |
2404 inline Matrix | |
2405 xform_translate (double x, double y, double z) | |
2406 { | |
2407 Matrix m = xform_matrix (); | |
2408 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
2409 return m; | |
2410 } | |
2411 | |
2412 inline void | |
2413 scale (Matrix& m, double x, double y, double z) | |
2414 { | |
2415 m = m * xform_scale (x, y, z); | |
2416 } | |
2417 | |
2418 inline void | |
2419 translate (Matrix& m, double x, double y, double z) | |
2420 { | |
2421 m = m * xform_translate (x, y, z); | |
2422 } | |
2423 | |
2424 inline void | |
2425 xform (ColumnVector& v, const Matrix& m) | |
2426 { | |
2427 v = m*v; | |
2428 } | |
2429 | |
2430 inline void | |
2431 scale (ColumnVector& v, double x, double y, double z) | |
2432 { | |
2433 v(0) *= x; | |
2434 v(1) *= y; | |
2435 v(2) *= z; | |
2436 } | |
2437 | |
2438 inline void | |
2439 translate (ColumnVector& v, double x, double y, double z) | |
2440 { | |
2441 v(0) += x; | |
2442 v(1) += y; | |
2443 v(2) += z; | |
2444 } | |
2445 | |
2446 inline void | |
2447 normalize (ColumnVector& v) | |
2448 { | |
2449 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); | |
2450 scale (v, fact, fact, fact); | |
2451 } | |
2452 | |
2453 inline double | |
2454 dot (const ColumnVector& v1, const ColumnVector& v2) | |
2455 { | |
2456 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
2457 } | |
2458 | |
2459 inline double | |
2460 norm (const ColumnVector& v) | |
2461 { | |
2462 return sqrt (dot (v, v)); | |
2463 } | |
2464 | |
2465 inline ColumnVector | |
2466 cross (const ColumnVector& v1, const ColumnVector& v2) | |
2467 { | |
2468 ColumnVector r = xform_vector (); | |
2469 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
2470 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
2471 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
2472 return r; | |
2473 } | |
2474 | |
2475 inline Matrix | |
2476 unit_cube (void) | |
2477 { | |
2478 static double data[32] = { | |
2479 0,0,0,1, | |
2480 1,0,0,1, | |
2481 0,1,0,1, | |
2482 0,0,1,1, | |
2483 1,1,0,1, | |
2484 1,0,1,1, | |
2485 0,1,1,1, | |
2486 1,1,1,1}; | |
2487 Matrix m (4, 8); | |
2488 memcpy (m.fortran_vec (), data, sizeof(double)*32); | |
2489 return m; | |
2490 } | |
2491 | |
2492 inline ColumnVector | |
2493 cam2xform (const Array<double>& m) | |
2494 { | |
2495 ColumnVector retval (4, 1.0); | |
2496 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); | |
2497 return retval; | |
2498 } | |
2499 | |
2500 inline RowVector | |
2501 xform2cam (const ColumnVector& v) | |
2502 { | |
2503 return v.extract_n (0, 3).transpose (); | |
2504 } | |
2505 | |
2506 void | |
2507 axes::properties::update_camera (void) | |
2508 { | |
2509 double xd = (xdir_is ("normal") ? 1 : -1); | |
2510 double yd = (ydir_is ("normal") ? 1 : -1); | |
2511 double zd = (zdir_is ("normal") ? 1 : -1); | |
2512 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2513 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
|
2514 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
|
2515 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
|
2516 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2517 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
|
2518 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
|
2519 double zo = zlimits(zd > 0 ? 0 : 1); |
7427 | 2520 |
2521 Matrix pb = get_plotboxaspectratio ().matrix_value (); | |
2522 | |
2523 bool autocam = (camerapositionmode_is ("auto") | |
2524 && cameratargetmode_is ("auto") | |
2525 && cameraupvectormode_is ("auto") | |
2526 && cameraviewanglemode_is ("auto")); | |
2527 bool dowarp = (autocam && dataaspectratiomode_is("auto") | |
2528 && plotboxaspectratiomode_is ("auto")); | |
2529 | |
2530 ColumnVector c_eye (xform_vector ()); | |
2531 ColumnVector c_center (xform_vector ()); | |
2532 ColumnVector c_upv (xform_vector ()); | |
2533 | |
2534 if (cameratargetmode_is ("auto")) | |
2535 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2536 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
|
2537 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
|
2538 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 2539 |
2540 cameratarget = xform2cam (c_center); | |
2541 } | |
2542 else | |
2543 c_center = cam2xform (get_cameratarget ().matrix_value ()); | |
2544 | |
2545 if (camerapositionmode_is ("auto")) | |
2546 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2547 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
|
2548 double az = tview(0), el = tview(1); |
7427 | 2549 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
2550 | |
2551 if (el == 90 || el == -90) | |
2552 c_eye(2) = d*signum(el); | |
2553 else | |
2554 { | |
2555 az *= M_PI/180.0; | |
2556 el *= M_PI/180.0; | |
2557 c_eye(0) = d*cos(el)*sin(az); | |
2558 c_eye(1) = -d*cos(el)*cos(az); | |
2559 c_eye(2) = d*sin(el); | |
2560 } | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2561 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
|
2562 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
|
2563 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 2564 |
2565 cameraposition = xform2cam (c_eye); | |
2566 } | |
2567 else | |
2568 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
2569 | |
2570 if (cameraupvectormode_is ("auto")) | |
2571 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2572 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
|
2573 double az = tview(0), el = tview(1); |
7427 | 2574 |
2575 if (el == 90 || el == -90) | |
2576 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2577 c_upv(0) = -sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2578 c_upv(1) = cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1); |
7427 | 2579 } |
2580 else | |
2581 c_upv(2) = 1; | |
2582 | |
2583 cameraupvector = xform2cam (c_upv); | |
2584 } | |
2585 else | |
2586 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
2587 | |
2588 Matrix x_view = xform_matrix (); | |
2589 Matrix x_projection = xform_matrix (); | |
2590 Matrix x_viewport = xform_matrix (); | |
2591 Matrix x_normrender = xform_matrix (); | |
2592 Matrix x_pre = xform_matrix (); | |
2593 | |
2594 x_render = xform_matrix (); | |
2595 x_render_inv = xform_matrix (); | |
2596 | |
2597 scale (x_pre, pb(0), pb(1), pb(2)); | |
2598 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
|
2599 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2600 zd/(zlimits(1)-zlimits(0))); |
7427 | 2601 translate (x_pre, -xo, -yo, -zo); |
2602 | |
2603 xform (c_eye, x_pre); | |
2604 xform (c_center, x_pre); | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2605 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)), |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2606 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 2607 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
2608 | |
2609 ColumnVector F (c_center), f (F), UP (c_upv); | |
2610 normalize (f); | |
2611 normalize (UP); | |
2612 | |
7440 | 2613 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 2614 { |
2615 double fa = 1/sqrt(1-f(2)*f(2)); | |
2616 scale (UP, fa, fa, fa); | |
2617 } | |
2618 | |
2619 ColumnVector s = cross (f, UP); | |
2620 ColumnVector u = cross (s, f); | |
2621 | |
2622 scale (x_view, 1, 1, -1); | |
2623 Matrix l = xform_matrix (); | |
2624 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
2625 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
2626 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
2627 x_view = x_view * l; | |
2628 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
2629 scale (x_view, pb(0), pb(1), pb(2)); | |
2630 translate (x_view, -0.5, -0.5, -0.5); | |
2631 | |
2632 Matrix x_cube = x_view * unit_cube (); | |
2633 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max (); | |
2634 double xM = cmax(0)-cmin(0); | |
2635 double yM = cmax(1)-cmin(1); | |
2636 | |
7447 | 2637 Matrix bb = get_boundingbox (true); |
7427 | 2638 |
2639 double v_angle; | |
2640 | |
2641 if (cameraviewanglemode_is ("auto")) | |
2642 { | |
2643 double af; | |
2644 | |
2645 // FIXME: Was this really needed? When compared to Matlab, it | |
2646 // does not seem to be required. Need investigation with concrete | |
2647 // backend to see results visually. | |
2648 if (false && dowarp) | |
2649 af = 1.0 / (xM > yM ? xM : yM); | |
2650 else | |
2651 { | |
2652 if ((bb(2)/bb(3)) > (xM/yM)) | |
2653 af = 1.0 / yM; | |
2654 else | |
2655 af = 1.0 / xM; | |
2656 } | |
2657 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
2658 | |
2659 cameraviewangle = v_angle; | |
2660 } | |
2661 else | |
2662 v_angle = get_cameraviewangle (); | |
2663 | |
2664 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
2665 scale (x_projection, pf, pf, 1); | |
2666 | |
2667 if (dowarp) | |
2668 { | |
2669 xM *= pf; | |
2670 yM *= pf; | |
7447 | 2671 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 2672 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
2673 } | |
2674 else | |
2675 { | |
2676 double pix = 1; | |
2677 if (autocam) | |
2678 { | |
2679 if ((bb(2)/bb(3)) > (xM/yM)) | |
2680 pix = bb(3); | |
2681 else | |
2682 pix = bb(2); | |
2683 } | |
2684 else | |
2685 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); | |
7447 | 2686 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 2687 scale (x_viewport, pix, -pix, 1); |
2688 } | |
2689 | |
2690 x_normrender = x_viewport * x_projection * x_view; | |
2691 | |
2692 x_cube = x_normrender * unit_cube (); | |
2693 cmin = x_cube.row_min (); | |
2694 cmax = x_cube.row_max (); | |
2695 x_zlim.resize (1, 2); | |
2696 x_zlim(0) = cmin(2); | |
2697 x_zlim(1) = cmax(2); | |
2698 | |
2699 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
|
2700 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2701 zd/(zlimits(1)-zlimits(0))); |
7427 | 2702 translate (x_render, -xo, -yo, -zo); |
2703 | |
2704 x_viewtransform = x_view; | |
2705 x_projectiontransform = x_projection; | |
2706 x_viewporttransform = x_viewport; | |
2707 x_normrendertransform = x_normrender; | |
2708 x_rendertransform = x_render; | |
2709 | |
2710 x_render_inv = x_render.inverse (); | |
2711 | |
2712 // Note: these matrices are a slight modified version of the regular | |
2713 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
2714 // => x_gl_mat2) | |
2715 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
|
2716 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2717 zd/(zlimits(1)-zlimits(0))); |
7427 | 2718 translate (x_gl_mat1, -xo, -yo, -zo); |
2719 x_gl_mat2 = x_viewport * x_projection; | |
2720 } | |
2721 | |
2722 void | |
2723 axes::properties::update_aspectratios (void) | |
2724 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2725 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
|
2726 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
|
2727 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
|
2728 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
2729 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
|
2730 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
|
2731 double dz = (zlimits(1)-zlimits(0)); |
7427 | 2732 |
2733 if (dataaspectratiomode_is ("auto")) | |
2734 { | |
2735 double dmin = xmin (xmin (dx, dy), dz); | |
2736 Matrix da (1, 3, 0.0); | |
2737 | |
2738 da(0) = dx/dmin; | |
2739 da(1) = dy/dmin; | |
2740 da(2) = dz/dmin; | |
2741 | |
2742 dataaspectratio = da; | |
2743 } | |
2744 | |
2745 if (plotboxaspectratiomode_is ("auto")) | |
2746 { | |
2747 if (dataaspectratiomode_is ("auto")) | |
2748 plotboxaspectratio = Matrix (1, 3, 1.0); | |
2749 else | |
2750 { | |
2751 Matrix da = get_dataaspectratio ().matrix_value (); | |
2752 Matrix pba (1, 3, 0.0); | |
2753 | |
2754 pba(0) = dx/da(0); | |
2755 pba(1) = dy/da(1); | |
2756 pba(2) = dz/da(2); | |
2757 } | |
2758 } | |
2759 | |
2760 // FIXME: if plotboxaspectratiomode is "manual", limits | |
2761 // and/or dataaspectratio might be adapted | |
2762 } | |
2763 | |
7447 | 2764 // The INTERNAL flag defines whether position or outerposition is used. |
2765 | |
7427 | 2766 Matrix |
7447 | 2767 axes::properties::get_boundingbox (bool internal) const |
7427 | 2768 { |
7447 | 2769 graphics_object obj = gh_manager::get_object (get_parent ()); |
2770 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); | |
2771 Matrix pos = (internal ? | |
2772 get_position ().matrix_value () | |
2773 : get_outerposition ().matrix_value ()); | |
2774 | |
2775 | |
2776 pos = convert_position (pos, get_units (), "pixels", | |
2777 parent_bb.extract_n (0, 2, 1, 2), get_backend ()); | |
7427 | 2778 pos(0)--; |
2779 pos(1)--; | |
7447 | 2780 pos(1) = parent_bb(3) - pos(1) - pos(3); |
7427 | 2781 |
2782 return pos; | |
2783 } | |
2784 | |
7435 | 2785 ColumnVector |
2786 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 2787 { |
2788 return ::xform_vector (x, y, z); | |
2789 } | |
7435 | 2790 |
2791 Matrix | |
2792 graphics_xform::xform_eye (void) | |
7869 | 2793 { |
2794 return ::xform_matrix (); | |
2795 } | |
7435 | 2796 |
2797 ColumnVector | |
2798 graphics_xform::transform (double x, double y, double z, | |
2799 bool use_scale) const | |
2800 { | |
2801 if (use_scale) | |
2802 { | |
2803 x = sx.scale (x); | |
2804 y = sy.scale (y); | |
2805 z = sz.scale (z); | |
2806 } | |
2807 | |
2808 return ::transform (xform, x, y, z); | |
2809 } | |
2810 | |
2811 ColumnVector | |
2812 graphics_xform::untransform (double x, double y, double z, | |
2813 bool use_scale) const | |
2814 { | |
2815 ColumnVector v = ::transform (xform_inv, x, y, z); | |
2816 | |
2817 if (use_scale) | |
2818 { | |
2819 v(0) = sx.unscale (v(0)); | |
2820 v(1) = sy.unscale (v(1)); | |
2821 v(2) = sz.unscale (v(2)); | |
2822 } | |
2823 | |
2824 return v; | |
2825 } | |
2826 | |
6836 | 2827 octave_value |
7189 | 2828 axes::get_default (const caseless_str& name) const |
6836 | 2829 { |
2830 octave_value retval = default_properties.lookup (name); | |
2831 | |
2832 if (retval.is_undefined ()) | |
2833 { | |
2834 graphics_handle parent = get_parent (); | |
2835 graphics_object parent_obj = gh_manager::get_object (parent); | |
2836 | |
2837 retval = parent_obj.get_default (name); | |
2838 } | |
2839 | |
2840 return retval; | |
2841 } | |
2842 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2843 // FIXME: Remove |
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
|
2844 // 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
|
2845 /* |
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
|
2846 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
|
2847 check_limit_vals (double& min_val, double& max_val, double& 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
|
2848 const array_property& data) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
2849 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
2850 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
|
2851 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
|
2852 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
|
2853 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
|
2854 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
|
2855 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
|
2856 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
|
2857 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
|
2858 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
|
2859 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2860 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2861 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2862 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
|
2863 check_limit_vals (double& min_val, double& max_val, double& min_pos, |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2864 const octave_value& data) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2865 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2866 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
|
2867 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2868 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
|
2869 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2870 if (! error_state && m.numel () == 3) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2871 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2872 double val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2873 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2874 val = m(0); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2875 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2876 min_val = val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2877 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2878 val = m(1); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2879 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2880 max_val = val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2881 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2882 val = m(2); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2883 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2884 min_pos = val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2885 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2886 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2887 } |
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
|
2888 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2889 // 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
|
2890 // integral. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2891 |
7869 | 2892 static void |
2893 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
|
2894 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2895 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2896 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2897 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2898 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2899 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2900 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2901 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2902 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
|
2903 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
|
2904 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
|
2905 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
|
2906 if (a < 1) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2907 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2908 a *= 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2909 b -= 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2910 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2911 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2912 if (x < 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2913 a = -a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2914 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2915 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2916 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2917 // 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
|
2918 // 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
|
2919 // FIXME -- add log ticks |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2920 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2921 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2922 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
|
2923 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2924 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2925 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2926 // 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
|
2927 // 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
|
2928 // 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
|
2929 // 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
|
2930 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2931 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2932 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2933 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2934 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
|
2935 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2936 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
|
2937 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
|
2938 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
|
2939 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2940 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2941 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2942 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2943 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2944 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2945 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2946 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2947 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2948 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2949 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
|
2950 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2951 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2952 |
7222 | 2953 // Attempt to make "nice" limits from the actual max and min of the |
2954 // data. For log plots, we will also use the smallest strictly positive | |
2955 // value. | |
2956 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
2957 Matrix |
7869 | 2958 axes::properties::get_axis_limits (double xmin, double xmax, |
2959 double min_pos, bool logscale) | |
7222 | 2960 { |
2961 Matrix retval; | |
2962 | |
2963 double min_val = xmin; | |
2964 double max_val = xmax; | |
2965 | |
2966 if (! (xisinf (min_val) || xisinf (max_val))) | |
2967 { | |
2968 if (logscale) | |
2969 { | |
2970 if (xisinf (min_pos)) | |
2971 { | |
2972 // warning ("axis: logscale with no positive values to plot"); | |
2973 return retval; | |
2974 } | |
2975 | |
2976 if (min_val <= 0) | |
2977 { | |
2978 warning ("axis: omitting nonpositive data in log plot"); | |
2979 min_val = min_pos; | |
2980 } | |
2981 // FIXME -- maybe this test should also be relative? | |
2982 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) | |
2983 { | |
2984 min_val *= 0.9; | |
2985 max_val *= 1.1; | |
2986 } | |
2987 min_val = pow (10, floor (log10 (min_val))); | |
2988 max_val = pow (10, ceil (log10 (max_val))); | |
2989 } | |
2990 else | |
2991 { | |
2992 if (min_val == 0 && max_val == 0) | |
2993 { | |
2994 min_val = -1; | |
2995 max_val = 1; | |
2996 } | |
2997 // FIXME -- maybe this test should also be relative? | |
2998 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) | |
2999 { | |
3000 min_val -= 0.1 * std::abs (min_val); | |
3001 max_val += 0.1 * std::abs (max_val); | |
3002 } | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3003 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3004 double tick_sep = calc_tick_sep (min_val , max_val); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3005 min_val = tick_sep * std::floor (min_val / tick_sep); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3006 max_val = tick_sep * ceil (max_val / tick_sep); |
7222 | 3007 } |
3008 } | |
3009 | |
3010 retval.resize (1, 2); | |
3011 | |
3012 retval(0) = min_val; | |
3013 retval(1) = max_val; | |
3014 | |
3015 return retval; | |
3016 } | |
3017 | |
7446 | 3018 void |
7869 | 3019 axes::properties::calc_ticks_and_lims (array_property& lims, |
3020 array_property& ticks, | |
3021 bool limmode_is_auto, bool is_logscale) | |
7446 | 3022 { |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3023 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3024 // FIXME -- add log ticks and lims |
7446 | 3025 |
3026 if (lims.get ().is_empty ()) | |
3027 return; | |
3028 | |
3029 double lo = (lims.get ().matrix_value ()) (0); | |
3030 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
|
3031 // FIXME should this be checked for somewhere else? (i.e. set{x,y,z}lim) |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3032 if (hi < lo) |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3033 { |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3034 double tmp = hi; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3035 hi = lo; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3036 lo = tmp; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
3037 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3038 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3039 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3040 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3041 // 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
|
3042 hi = std::log10 (hi); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3043 lo = std::log10 (lo); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3044 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3045 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3046 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
|
3047 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3048 int i1 = static_cast<int> (std::floor (lo / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3049 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
|
3050 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3051 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3052 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3053 // 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
|
3054 Matrix tmp_lims (1,2); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3055 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
|
3056 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
|
3057 |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3058 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3059 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3060 tmp_lims(0) = std::pow (10.,tmp_lims(0)); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3061 tmp_lims(1) = std::pow (10.,tmp_lims(1)); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3062 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3063 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3064 } |
7446 | 3065 else |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3066 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3067 // 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
|
3068 i1 = static_cast<int> (std::ceil (lo / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3069 i2 = static_cast<int> (std::floor (hi / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3070 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3071 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3072 Matrix tmp_ticks (1, i2-i1+1); |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3073 for (int i = 0; i <= i2-i1; i++) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3074 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3075 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
|
3076 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3077 tmp_ticks (i) = std::pow (10., tmp_ticks (i)); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
3078 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3079 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3080 ticks = tmp_ticks; |
7446 | 3081 } |
3082 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3083 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
|
3084 get_children_limits (double& min_val, double& max_val, double& min_pos, |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3085 const Matrix& kids, char 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
|
3086 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3087 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
|
3088 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3089 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
|
3090 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3091 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
|
3092 for (octave_idx_type i = 0; i < n; i++) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3093 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3094 graphics_object obj = gh_manager::get_object (kids(i)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3095 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3096 if (obj.is_xliminclude ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3097 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3098 octave_value lim = obj.get_xlim (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3099 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3100 check_limit_vals (min_val, max_val, min_pos, lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3101 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3102 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3103 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3104 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3105 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
|
3106 for (octave_idx_type i = 0; i < n; i++) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3107 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3108 graphics_object obj = gh_manager::get_object (kids(i)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3109 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3110 if (obj.is_yliminclude ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3111 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3112 octave_value lim = obj.get_ylim (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3113 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3114 check_limit_vals (min_val, max_val, min_pos, lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3115 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3116 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3117 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3118 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3119 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
|
3120 for (octave_idx_type i = 0; i < n; i++) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3121 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3122 graphics_object obj = gh_manager::get_object (kids(i)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3123 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3124 if (obj.is_zliminclude ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3125 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3126 octave_value lim = obj.get_zlim (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3127 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3128 check_limit_vals (min_val, max_val, min_pos, lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3129 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3130 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3131 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3132 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3133 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
|
3134 for (octave_idx_type i = 0; i < n; i++) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3135 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3136 graphics_object obj = gh_manager::get_object (kids(i)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3137 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3138 if (obj.is_climinclude ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3139 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3140 octave_value lim = obj.get_clim (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3141 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3142 check_limit_vals (min_val, max_val, min_pos, lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3143 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3144 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3145 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3146 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3147 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
|
3148 for (octave_idx_type i = 0; i < n; i++) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3149 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3150 graphics_object obj = gh_manager::get_object (kids(i)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3151 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3152 if (obj.is_aliminclude ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3153 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3154 octave_value lim = obj.get_alim (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3155 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3156 check_limit_vals (min_val, max_val, min_pos, lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3157 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3158 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3159 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3160 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3161 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3162 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3163 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3164 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3165 |
7222 | 3166 static bool updating_axis_limits = false; |
3167 | |
7214 | 3168 void |
7222 | 3169 axes::update_axis_limits (const std::string& axis_type) |
7214 | 3170 { |
7222 | 3171 if (updating_axis_limits) |
3172 return; | |
3173 | |
3174 Matrix kids = xproperties.get_children (); | |
3175 | |
3176 double min_val = octave_Inf; | |
3177 double max_val = -octave_Inf; | |
3178 double min_pos = octave_Inf; | |
3179 | |
3180 char update_type = 0; | |
3181 | |
3182 Matrix limits; | |
3183 | |
3184 if (axis_type == "xdata" || axis_type == "xscale" | |
3185 || axis_type == "xldata" || axis_type == "xudata" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3186 || 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
|
3187 || axis_type == "xlim") |
7222 | 3188 { |
7363 | 3189 if (xproperties.xlimmode_is ("auto")) |
7222 | 3190 { |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3191 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3192 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3193 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3194 xproperties.xscale_is ("log")); |
7222 | 3195 |
3196 update_type = 'x'; | |
3197 } | |
3198 } | |
3199 else if (axis_type == "ydata" || axis_type == "yscale" | |
3200 || axis_type == "ldata" || axis_type == "udata" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3201 || axis_type == "ylimmode" || axis_type == "yliminclude" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3202 || axis_type == "ylim") |
7222 | 3203 { |
7363 | 3204 if (xproperties.ylimmode_is ("auto")) |
7222 | 3205 { |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3206 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
7222 | 3207 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3208 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3209 xproperties.yscale_is ("log")); |
7222 | 3210 |
3211 update_type = 'y'; | |
3212 } | |
3213 } | |
3214 else if (axis_type == "zdata" || axis_type == "zscale" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3215 || axis_type == "zlimmode" || axis_type == "zliminclude" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3216 || axis_type == "zlim") |
7222 | 3217 { |
7363 | 3218 if (xproperties.zlimmode_is ("auto")) |
7222 | 3219 { |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3220 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
7222 | 3221 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3222 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
3223 xproperties.zscale_is ("log")); |
7222 | 3224 |
3225 update_type = 'z'; | |
3226 } | |
3227 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3228 else if (axis_type == "cdata" || axis_type == "climmode" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3229 || axis_type == "cdatamapping" || axis_type == "climinclude" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3230 || axis_type == "clim") |
7222 | 3231 { |
7363 | 3232 if (xproperties.climmode_is ("auto")) |
7222 | 3233 { |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3234 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3235 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3236 if (min_val > max_val) |
7222 | 3237 { |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3238 min_val = min_pos = 0; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3239 max_val = 1; |
7222 | 3240 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3241 else if (min_val == max_val) |
7222 | 3242 max_val = min_val + 1; |
3243 | |
3244 limits.resize (1, 2); | |
3245 | |
3246 limits(0) = min_val; | |
3247 limits(1) = max_val; | |
3248 | |
3249 update_type = 'c'; | |
3250 } | |
3251 | |
3252 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3253 else if (axis_type == "alphadata" || axis_type == "alimmode" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3254 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3255 || axis_type == "alim") |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3256 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3257 if (xproperties.alimmode_is ("auto")) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3258 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3259 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3260 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3261 if (min_val > max_val) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3262 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3263 min_val = min_pos = 0; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3264 max_val = 1; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3265 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3266 else if (min_val == max_val) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3267 max_val = min_val + 1; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3268 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3269 limits.resize (1, 2); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3270 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3271 limits(0) = min_val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3272 limits(1) = max_val; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3273 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3274 update_type = 'a'; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3275 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3276 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3277 } |
7222 | 3278 |
3279 unwind_protect_bool (updating_axis_limits); | |
3280 updating_axis_limits = true; | |
3281 | |
3282 switch (update_type) | |
3283 { | |
3284 case 'x': | |
3285 xproperties.set_xlim (limits); | |
3286 xproperties.set_xlimmode ("auto"); | |
7446 | 3287 xproperties.update_xlim (); |
7222 | 3288 break; |
3289 | |
3290 case 'y': | |
3291 xproperties.set_ylim (limits); | |
3292 xproperties.set_ylimmode ("auto"); | |
7446 | 3293 xproperties.update_ylim (); |
7222 | 3294 break; |
3295 | |
3296 case 'z': | |
3297 xproperties.set_zlim (limits); | |
3298 xproperties.set_zlimmode ("auto"); | |
7446 | 3299 xproperties.update_zlim (); |
7222 | 3300 break; |
3301 | |
3302 case 'c': | |
3303 xproperties.set_clim (limits); | |
3304 xproperties.set_climmode ("auto"); | |
3305 break; | |
3306 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3307 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
|
3308 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
|
3309 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
|
3310 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3311 |
7222 | 3312 default: |
3313 break; | |
3314 } | |
3315 | |
7427 | 3316 xproperties.update_transform (); |
3317 | |
7222 | 3318 unwind_protect::run (); |
7214 | 3319 } |
3320 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3321 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3322 axes::properties::zoom (const Matrix& xl, const Matrix& yl) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3323 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3324 zoom_stack.push_front (xlimmode.get ()); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3325 zoom_stack.push_front (xlim.get ()); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3326 zoom_stack.push_front (ylimmode.get ()); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3327 zoom_stack.push_front (ylim.get ()); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3328 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3329 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3330 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3331 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3332 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3333 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3334 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3335 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3336 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3337 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3338 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3339 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3340 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3341 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3342 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3343 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3344 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3345 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3346 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3347 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3348 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3349 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3350 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3351 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3352 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3353 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3354 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3355 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3356 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3357 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3358 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3359 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3360 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3361 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3362 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3363 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3364 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3365 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3366 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
3367 |
7363 | 3368 // --------------------------------------------------------------------- |
3369 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3370 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3371 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
|
3372 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3373 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
|
3374 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3375 m(0) = xmin (xdata.min_val (), xmin (xldata.min_val (), xudata.min_val ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3376 m(1) = xmax (xdata.max_val (), xmax (xldata.max_val (), xudata.max_val ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3377 m(2) = xmin (xdata.min_pos (), xmin (xldata.min_pos (), xudata.min_pos ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3378 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3379 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
|
3380 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3381 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3382 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3383 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
|
3384 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3385 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
|
3386 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3387 m(0) = xmin (ydata.min_val (), xmin (ldata.min_val (), udata.min_val ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3388 m(1) = xmax (ydata.max_val (), xmax (ldata.max_val (), udata.max_val ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3389 m(2) = xmin (ydata.min_pos (), xmin (ldata.min_pos (), udata.min_pos ())); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3390 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3391 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
|
3392 } |
6406 | 3393 |
3394 // --------------------------------------------------------------------- | |
3395 | |
7363 | 3396 // Note: "text" code is entirely auto-generated |
6406 | 3397 |
3398 // --------------------------------------------------------------------- | |
3399 | |
7363 | 3400 // Note: "image" code is entirely auto-generated |
6406 | 3401 |
3402 // --------------------------------------------------------------------- | |
3403 | |
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
|
3404 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
|
3405 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
|
3406 { |
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
|
3407 return convert_cdata (*this, get_facevertexcdata (), |
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
|
3408 cdatamapping_is ("scaled"), 2); |
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
|
3409 } |
6807 | 3410 |
3411 // --------------------------------------------------------------------- | |
3412 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3413 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3414 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
|
3415 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3416 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
|
3417 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3418 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3419 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3420 cross_product (double x1, double y1, double z1, |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3421 double x2, double y2, double z2, |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3422 double& x, double& y, double& z) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3423 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3424 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
|
3425 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
|
3426 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
|
3427 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3428 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3429 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3430 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
|
3431 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3432 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3433 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3434 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
|
3435 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
|
3436 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
|
3437 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3438 int p = z.columns (), q = z.rows (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3439 int i1, i2, i3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3440 int j1, j2, j3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3441 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3442 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
|
3443 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
|
3444 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3445 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
|
3446 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3447 i1 = i2 = i3 = 0; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3448 j1 = j2 = j3 = 0; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3449 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3450 // FIXME: normal computation at boundaries |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3451 for (int i = 1; i < (p-1); i++) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3452 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3453 if (y_mat) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3454 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3455 i1 = i-1; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3456 i2 = i; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3457 i3 = i+1; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3458 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3459 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3460 for (int j = 1; j < (q-1); j++) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3461 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3462 if (x_mat) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3463 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3464 j1 = j-1; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3465 j2 = j; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3466 j3 = j+1; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3467 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3468 |
7871 | 3469 double& nx = n(j,i,0); |
3470 double& ny = n(j,i,1); | |
3471 double& nz = n(j,i,2); | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3472 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3473 cross_product (x(j3,i)-x(j2,i), y(j+1,i2)-y(j,i2), z(j+1,i)-z(j,i), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3474 x(j2,i+1)-x(j2,i), y(j,i3)-y(j,i2), z(j,i+1)-z(i,j), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3475 nx, ny, nz); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3476 cross_product (x(j2,i-1)-x(j2,i), y(j,i1)-y(j,i2), z(j,i-1)-z(j,i), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3477 x(j3,i)-x(j2,i), y(j+1,i2)-y(j,i2), z(j+1,i)-z(i,j), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3478 nx, ny, nz); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3479 cross_product (x(j1,i)-x(j2,i), y(j-1,i2)-y(j,i2), z(j-1,i)-z(j,i), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3480 x(j2,i-1)-x(j2,i), y(j,i1)-y(j,i2), z(j,i-1)-z(i,j), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3481 nx, ny, nz); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3482 cross_product (x(j2,i+1)-x(j2,i), y(j,i3)-y(j,i2), z(j,i+1)-z(j,i), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3483 x(j1,i)-x(j2,i), y(j-1,i2)-y(j,i2), z(j-1,i)-z(i,j), |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3484 nx, ny, nz); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3485 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3486 double d = - sqrt (nx*nx + ny*ny + nz*nz); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3487 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3488 nx /= d; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3489 ny /= d; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3490 nz /= d; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3491 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3492 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3493 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3494 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3495 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3496 } |
6406 | 3497 |
3498 // --------------------------------------------------------------------- | |
3499 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3500 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3501 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3502 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3503 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3504 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3505 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3506 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3507 double min_pos = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3508 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3509 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3510 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
3511 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3512 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3513 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3514 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3515 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3516 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
3517 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3518 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3519 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
|
3520 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3521 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3522 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
3523 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3524 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3525 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
|
3526 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3527 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3528 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
3529 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3530 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3531 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
|
3532 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3533 update_type = 'c'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3534 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3535 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
3536 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3537 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3538 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
|
3539 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3540 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3541 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3542 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3543 Matrix limits (1, 3, 0.0); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3544 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3545 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3546 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3547 limits(2) = min_pos; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3548 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3549 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3550 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3551 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3552 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3553 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3554 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3555 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3556 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3557 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3558 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3559 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3560 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3561 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3562 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3563 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3564 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3565 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3566 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3567 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3568 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3569 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3570 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3571 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3572 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3573 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3574 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3575 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3576 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3577 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3578 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3579 |
6406 | 3580 octave_value |
7189 | 3581 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 3582 { |
3583 graphics_handle parent = get_parent (); | |
3584 graphics_object parent_obj = gh_manager::get_object (parent); | |
3585 | |
3586 return parent_obj.get_default (type () + name); | |
3587 } | |
3588 | |
3589 octave_value | |
7189 | 3590 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 3591 { |
3592 graphics_object parent_obj = gh_manager::get_object (0); | |
3593 | |
3594 return parent_obj.get_factory_default (type () + name); | |
3595 } | |
3596 | |
7286 | 3597 // We use a random value for the handle to avoid issues with plots and |
3598 // scalar values for the first argument. | |
6406 | 3599 gh_manager::gh_manager (void) |
7286 | 3600 : handle_map (), handle_free_list (), |
3601 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)) | |
6406 | 3602 { |
3603 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3604 |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3605 // Make sure the default backend is registered. |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3606 graphics_backend::default_backend (); |
6406 | 3607 } |
3608 | |
3609 graphics_handle | |
3610 gh_manager::do_make_graphics_handle (const std::string& go_name, | |
7370 | 3611 const graphics_handle& p, bool do_createfcn) |
6406 | 3612 { |
3613 graphics_handle h = get_handle (go_name); | |
3614 | |
3615 base_graphics_object *go = 0; | |
3616 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
3617 go = make_graphics_object_from_type (go_name, h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
3618 |
6406 | 3619 if (go) |
7370 | 3620 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3621 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3622 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3623 handle_map[h] = obj; |
7370 | 3624 if (do_createfcn) |
3625 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3626 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3627 // notify backend |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3628 graphics_backend backend = go->get_backend (); |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3629 if (backend) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3630 backend.object_created (obj); |
7370 | 3631 } |
6406 | 3632 else |
3633 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", | |
3634 go_name.c_str ()); | |
3635 | |
3636 return h; | |
3637 } | |
3638 | |
3639 graphics_handle | |
3640 gh_manager::do_make_figure_handle (double val) | |
3641 { | |
3642 graphics_handle h = val; | |
3643 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3644 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
|
3645 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3646 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3647 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3648 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3649 // notify backend |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3650 graphics_backend backend = go->get_backend (); |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3651 if (backend) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3652 backend.object_created (obj); |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
3653 |
6406 | 3654 return h; |
3655 } | |
3656 | |
3657 void | |
3658 gh_manager::do_push_figure (const graphics_handle& h) | |
3659 { | |
3660 do_pop_figure (h); | |
3661 | |
3662 figure_list.push_front (h); | |
3663 } | |
3664 | |
3665 void | |
3666 gh_manager::do_pop_figure (const graphics_handle& h) | |
3667 { | |
3668 for (figure_list_iterator p = figure_list.begin (); | |
3669 p != figure_list.end (); | |
3670 p++) | |
3671 { | |
3672 if (*p == h) | |
3673 { | |
3674 figure_list.erase (p); | |
3675 break; | |
3676 } | |
3677 } | |
3678 } | |
3679 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3680 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3681 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
|
3682 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3683 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3684 callback_event (const graphics_handle& h, const std::string& name, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3685 const octave_value& data = Matrix ()) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3686 : 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
|
3687 callback_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3688 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3689 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3690 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3691 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
|
3692 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3693 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3694 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3695 callback_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3696 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3697 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3698 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3699 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3700 std::string callback_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3701 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3702 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3703 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3704 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3705 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
|
3706 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3707 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3708 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
|
3709 : base_graphics_event (), function (fcn), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3710 function_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3711 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3712 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3713 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3714 function (function_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3715 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3716 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3717 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3718 function_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3719 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3720 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3721 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3722 graphics_event::event_fcn function; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3723 void* function_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3724 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3725 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3726 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3727 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
|
3728 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3729 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3730 set_event (const graphics_handle& h, const std::string& name, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3731 const octave_value& value) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3732 : 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
|
3733 property_value (value) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3734 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3735 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3736 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3737 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3738 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3739 xset (handle, property_name, property_value); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3740 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3741 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3742 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3743 set_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3744 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3745 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3746 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3747 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3748 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3749 octave_value property_value; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3750 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3751 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3752 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3753 graphics_event::create_callback_event (const graphics_handle& h, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3754 const std::string& name, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3755 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3756 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3757 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3758 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3759 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
|
3760 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3761 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3762 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3763 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3764 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3765 graphics_event::create_function_event (graphics_event::event_fcn fcn, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3766 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3767 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3768 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3769 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3770 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
|
3771 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3772 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3773 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3774 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3775 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3776 graphics_event::create_set_event (const graphics_handle& h, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3777 const std::string& name, |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3778 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3779 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3780 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3781 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3782 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
|
3783 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3784 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3785 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3786 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3787 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3788 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3789 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3790 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
|
3791 root_figure::properties& props = |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3792 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
|
3793 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3794 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
|
3795 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3796 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3797 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3798 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3799 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3800 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3801 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3802 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3803 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3804 xset_gcbo (callback_objects.empty () |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3805 ? graphics_handle () |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3806 : callback_objects.front ().get_handle ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3807 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3808 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3809 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3810 gh_manager::do_execute_callback (const graphics_handle& h, |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3811 const octave_value& cb_arg, |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3812 const octave_value& data) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3813 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3814 octave_value_list args; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3815 octave_function *fcn = 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3816 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3817 args(0) = h.as_octave_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3818 if (data.is_defined ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3819 args(1) = data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3820 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3821 args(1) = Matrix (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3822 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3823 unwind_protect::begin_frame ("execute_callback"); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3824 unwind_protect::add (gh_manager::restore_gcbo); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3825 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3826 if (true) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3827 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3828 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3829 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3830 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
|
3831 xset_gcbo (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3832 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3833 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3834 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3835 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3836 // 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
|
3837 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3838 octave_value cb = cb_arg; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3839 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3840 if (cb.is_function_handle ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3841 fcn = cb.function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3842 else if (cb.is_string ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3843 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3844 int status; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3845 std::string s = cb.string_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3846 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3847 eval_string (s, false, status); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3848 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3849 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
|
3850 && (cb.rows () == 1 || cb.columns () == 1) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3851 && 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
|
3852 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3853 Cell c = cb.cell_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3854 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3855 fcn = c(0).function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3856 if (! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3857 { |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
3858 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
|
3859 args(1+i) = c(i); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3860 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3861 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3862 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3863 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3864 std::string nm = cb.class_name (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3865 error ("trying to execute non-executable object (class = %s)", |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3866 nm.c_str ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3867 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3868 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3869 if (fcn && ! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3870 feval (fcn, args); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3871 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3872 END_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3873 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3874 unwind_protect::run_frame ("execute_callback"); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3875 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3876 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3877 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3878 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
|
3879 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3880 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3881 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3882 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
|
3883 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3884 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3885 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3886 gh_manager::do_post_callback (const graphics_handle& h, const std::string name, |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3887 const octave_value& data) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3888 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3889 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3890 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3891 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3892 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3893 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3894 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3895 if (callback_objects.empty ()) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3896 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
|
3897 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3898 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3899 const graphics_object& current = callback_objects.front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3900 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3901 if (current.get_properties ().is_interruptible ()) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3902 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
|
3903 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3904 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3905 caseless_str busy_action (go.get_properties ().get_busyaction ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3906 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3907 if (busy_action.compare ("queue")) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3908 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
|
3909 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3910 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3911 caseless_str cname (name); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3912 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3913 if (cname.compare ("deletefcn") |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3914 || cname.compare ("createfcn") |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3915 || (go.isa ("figure") |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3916 && (cname.compare ("closerequestfcn") |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3917 || cname.compare ("resizefcn")))) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3918 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
|
3919 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3920 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3921 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3922 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3923 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3924 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3925 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3926 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
|
3927 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3928 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3929 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3930 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
|
3931 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3932 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3933 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3934 gh_manager::do_post_set (const graphics_handle& h, const std::string name, |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3935 const octave_value& value) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3936 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3937 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3938 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3939 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
|
3940 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3941 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3942 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3943 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
|
3944 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3945 graphics_event e; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3946 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3947 do |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3948 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3949 e = graphics_event (); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3950 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3951 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3952 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3953 if (! event_queue.empty ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3954 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3955 if (callback_objects.empty () || force) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3956 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3957 e = event_queue.front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3958 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3959 event_queue.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3960 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3961 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3962 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3963 const graphics_object& go = callback_objects.front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3964 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3965 if (go.get_properties ().is_interruptible ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3966 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3967 e = event_queue.front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3968 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3969 event_queue.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3970 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3971 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3972 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3973 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3974 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3975 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3976 if (e.ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3977 e.execute (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3978 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3979 while (e.ok ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3980 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3981 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3982 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3983 if (event_queue.empty ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3984 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
|
3985 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3986 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3987 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3988 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3989 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
3990 |
6406 | 3991 property_list::plist_map_type |
3992 root_figure::init_factory_properties (void) | |
3993 { | |
3994 property_list::plist_map_type plist_map; | |
3995 | |
6844 | 3996 plist_map["figure"] = figure::properties::factory_defaults (); |
3997 plist_map["axes"] = axes::properties::factory_defaults (); | |
3998 plist_map["line"] = line::properties::factory_defaults (); | |
3999 plist_map["text"] = text::properties::factory_defaults (); | |
4000 plist_map["image"] = image::properties::factory_defaults (); | |
4001 plist_map["patch"] = patch::properties::factory_defaults (); | |
4002 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4003 plist_map["hggroup"] = hggroup::properties::factory_defaults (); |
6406 | 4004 |
4005 return plist_map; | |
4006 } | |
4007 | |
4008 // --------------------------------------------------------------------- | |
4009 | |
4010 DEFUN (ishandle, args, , | |
4011 "-*- texinfo -*-\n\ | |
6678 | 4012 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 4013 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
4014 @end deftypefn") | |
4015 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4016 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4017 |
6406 | 4018 octave_value retval; |
4019 | |
4020 if (args.length () == 1) | |
4021 retval = is_handle (args(0)); | |
4022 else | |
4023 print_usage (); | |
4024 | |
4025 return retval; | |
4026 } | |
4027 | |
4028 DEFUN (set, args, , | |
4029 "-*- texinfo -*-\n\ | |
6678 | 4030 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ |
6732 | 4031 Set the named property value or vector @var{p} to the value @var{v}\n\ |
6894 | 4032 for the graphics handle @var{h}.\n\ |
6406 | 4033 @end deftypefn") |
4034 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4035 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4036 |
6406 | 4037 octave_value retval; |
4038 | |
4039 int nargin = args.length (); | |
4040 | |
4041 if (nargin > 0) | |
4042 { | |
6732 | 4043 ColumnVector hcv (args(0).vector_value ()); |
6406 | 4044 |
4045 if (! error_state) | |
6732 | 4046 { |
6733 | 4047 bool request_drawnow = false; |
4048 | |
6732 | 4049 for (octave_idx_type n = 0; n < hcv.length (); n++) |
4050 { | |
4051 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 4052 |
6732 | 4053 if (obj) |
4054 { | |
4055 obj.set (args.splice (0, 1)); | |
6406 | 4056 |
6733 | 4057 request_drawnow = true; |
6732 | 4058 } |
4059 else | |
6733 | 4060 { |
4061 error ("set: invalid handle (= %g)", hcv(n)); | |
4062 break; | |
4063 } | |
6732 | 4064 } |
6733 | 4065 |
4066 if (! error_state && request_drawnow) | |
7409 | 4067 Vdrawnow_requested = true; |
6732 | 4068 } |
6406 | 4069 else |
6732 | 4070 error ("set: expecting graphics handle as first argument"); |
6406 | 4071 } |
4072 else | |
4073 print_usage (); | |
4074 | |
4075 return retval; | |
4076 } | |
4077 | |
4078 DEFUN (get, args, , | |
4079 "-*- texinfo -*-\n\ | |
6678 | 4080 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406 | 4081 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
4082 If @var{p} is omitted, return the complete property list for @var{h}.\n\ | |
6732 | 4083 If @var{h} is a vector, return a cell array including the property\n\ |
4084 values or lists respectively.\n\ | |
6406 | 4085 @end deftypefn") |
4086 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4087 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4088 |
6406 | 4089 octave_value retval; |
6732 | 4090 octave_value_list vlist; |
6406 | 4091 |
4092 int nargin = args.length (); | |
4093 | |
4094 if (nargin == 1 || nargin == 2) | |
4095 { | |
6732 | 4096 ColumnVector hcv (args(0).vector_value ()); |
6406 | 4097 |
4098 if (! error_state) | |
6732 | 4099 { |
6733 | 4100 octave_idx_type len = hcv.length (); |
4101 | |
4102 vlist.resize (len); | |
4103 | |
4104 for (octave_idx_type n = 0; n < len; n++) | |
6732 | 4105 { |
4106 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 4107 |
6732 | 4108 if (obj) |
4109 { | |
4110 if (nargin == 1) | |
4111 vlist(n) = obj.get (); | |
4112 else | |
4113 { | |
7189 | 4114 caseless_str property = args(1).string_value (); |
6406 | 4115 |
6732 | 4116 if (! error_state) |
4117 vlist(n) = obj.get (property); | |
4118 else | |
6733 | 4119 { |
4120 error ("get: expecting property name as second argument"); | |
4121 break; | |
4122 } | |
6732 | 4123 } |
4124 } | |
4125 else | |
6733 | 4126 { |
4127 error ("get: invalid handle (= %g)", hcv(n)); | |
4128 break; | |
4129 } | |
6732 | 4130 } |
4131 } | |
6406 | 4132 else |
6732 | 4133 error ("get: expecting graphics handle as first argument"); |
6406 | 4134 } |
4135 else | |
4136 print_usage (); | |
4137 | |
6733 | 4138 if (! error_state) |
6732 | 4139 { |
6733 | 4140 octave_idx_type len = vlist.length (); |
4141 | |
4142 if (len > 1) | |
4143 retval = Cell (vlist); | |
4144 else if (len == 1) | |
4145 retval = vlist(0); | |
6732 | 4146 } |
4147 | |
6406 | 4148 return retval; |
4149 } | |
4150 | |
7379 | 4151 DEFUN (__get__, args, , |
4152 "-*- texinfo -*-\n\ | |
4153 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\ | |
4154 Return all properties from the graphics handle @var{h}.\n\ | |
4155 If @var{h} is a vector, return a cell array including the property\n\ | |
4156 values or lists respectively.\n\ | |
4157 @end deftypefn") | |
4158 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4159 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4160 |
7379 | 4161 octave_value retval; |
4162 octave_value_list vlist; | |
4163 | |
4164 int nargin = args.length (); | |
4165 | |
4166 if (nargin == 1) | |
4167 { | |
4168 ColumnVector hcv (args(0).vector_value ()); | |
4169 | |
4170 if (! error_state) | |
4171 { | |
4172 octave_idx_type len = hcv.length (); | |
4173 | |
4174 vlist.resize (len); | |
4175 | |
4176 for (octave_idx_type n = 0; n < len; n++) | |
4177 { | |
4178 graphics_object obj = gh_manager::get_object (hcv(n)); | |
4179 | |
4180 if (obj) | |
4181 vlist(n) = obj.get (true); | |
4182 else | |
4183 { | |
4184 error ("get: invalid handle (= %g)", hcv(n)); | |
4185 break; | |
4186 } | |
4187 } | |
4188 } | |
4189 else | |
4190 error ("get: expecting graphics handle as first argument"); | |
4191 } | |
4192 else | |
4193 print_usage (); | |
4194 | |
4195 if (! error_state) | |
4196 { | |
4197 octave_idx_type len = vlist.length (); | |
4198 | |
4199 if (len > 1) | |
4200 retval = Cell (vlist); | |
4201 else if (len == 1) | |
4202 retval = vlist(0); | |
4203 } | |
4204 | |
4205 return retval; | |
4206 } | |
4207 | |
6406 | 4208 static octave_value |
4209 make_graphics_object (const std::string& go_name, | |
6874 | 4210 const octave_value_list& args) |
6406 | 4211 { |
4212 octave_value retval; | |
4213 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4214 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4215 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4216 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4217 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4218 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4219 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4220 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4221 if (xargs(i).is_string () |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4222 && p.compare (xargs(i).string_value ())) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4223 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4224 if (i < (xargs.length () - 1)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4225 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4226 val = xargs(i+1).double_value (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4227 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4228 if (! error_state) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4229 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4230 xargs = xargs.splice (i, 2); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4231 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4232 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4233 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4234 else |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4235 error ("__go_%s__: missing value for parent property", |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4236 go_name.c_str ()); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4237 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4238 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4239 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4240 val = args(0).double_value (); |
6406 | 4241 |
4242 if (! error_state) | |
4243 { | |
4244 graphics_handle parent = gh_manager::lookup (val); | |
4245 | |
7056 | 4246 if (parent.ok ()) |
6406 | 4247 { |
4248 graphics_handle h | |
7370 | 4249 = gh_manager::make_graphics_handle (go_name, parent, false); |
6406 | 4250 |
4251 if (! error_state) | |
4252 { | |
4253 adopt (parent, h); | |
4254 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4255 xset (h, xargs); |
7370 | 4256 xcreatefcn (h); |
6406 | 4257 |
6874 | 4258 retval = h.value (); |
7296 | 4259 |
4260 if (! error_state) | |
7409 | 4261 Vdrawnow_requested = true; |
6406 | 4262 } |
4263 else | |
4264 error ("__go%s__: unable to create graphics handle", | |
4265 go_name.c_str ()); | |
4266 } | |
4267 else | |
4268 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
4269 } | |
4270 else | |
4271 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
4272 | |
4273 return retval; | |
4274 } | |
4275 | |
4276 DEFUN (__go_figure__, args, , | |
4277 "-*- texinfo -*-\n\ | |
4278 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ | |
6945 | 4279 Undocumented internal function.\n\ |
6406 | 4280 @end deftypefn") |
4281 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4282 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4283 |
6406 | 4284 octave_value retval; |
4285 | |
4286 if (args.length () > 0) | |
4287 { | |
4288 double val = args(0).double_value (); | |
4289 | |
4290 if (! error_state) | |
4291 { | |
4292 if (is_figure (val)) | |
4293 { | |
4294 graphics_handle h = gh_manager::lookup (val); | |
4295 | |
4296 xset (h, args.splice (0, 1)); | |
4297 | |
6874 | 4298 retval = h.value (); |
6406 | 4299 } |
4300 else | |
4301 { | |
4302 graphics_handle h = octave_NaN; | |
4303 | |
4304 if (xisnan (val)) | |
7370 | 4305 h = gh_manager::make_graphics_handle ("figure", 0, false); |
6406 | 4306 else if (val > 0 && D_NINT (val) == val) |
4307 h = gh_manager::make_figure_handle (val); | |
4308 else | |
4309 error ("__go_figure__: invalid figure number"); | |
4310 | |
7056 | 4311 if (! error_state && h.ok ()) |
6406 | 4312 { |
4313 adopt (0, h); | |
4314 | |
4315 xset (h, args.splice (0, 1)); | |
7370 | 4316 xcreatefcn (h); |
6406 | 4317 |
6874 | 4318 retval = h.value (); |
6406 | 4319 } |
4320 else | |
4321 error ("__go_figure__: failed to create figure handle"); | |
4322 } | |
4323 } | |
4324 else | |
4325 error ("__go_figure__: expecting figure number to be double value"); | |
4326 } | |
4327 else | |
4328 print_usage (); | |
4329 | |
4330 return retval; | |
4331 } | |
4332 | |
4333 #define GO_BODY(TYPE) \ | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4334 gh_manager::autolock guard; \ |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4335 \ |
6406 | 4336 octave_value retval; \ |
4337 \ | |
4338 if (args.length () > 0) \ | |
4339 retval = make_graphics_object (#TYPE, args); \ | |
4340 else \ | |
4341 print_usage (); \ | |
4342 \ | |
4343 return retval | |
4344 | |
4345 DEFUN (__go_axes__, args, , | |
4346 "-*- texinfo -*-\n\ | |
4347 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ | |
6945 | 4348 Undocumented internal function.\n\ |
6406 | 4349 @end deftypefn") |
4350 { | |
4351 GO_BODY (axes); | |
4352 } | |
4353 | |
4354 DEFUN (__go_line__, args, , | |
4355 "-*- texinfo -*-\n\ | |
4356 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ | |
6945 | 4357 Undocumented internal function.\n\ |
6406 | 4358 @end deftypefn") |
4359 { | |
4360 GO_BODY (line); | |
4361 } | |
4362 | |
4363 DEFUN (__go_text__, args, , | |
4364 "-*- texinfo -*-\n\ | |
4365 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ | |
6945 | 4366 Undocumented internal function.\n\ |
6406 | 4367 @end deftypefn") |
4368 { | |
4369 GO_BODY (text); | |
4370 } | |
4371 | |
4372 DEFUN (__go_image__, args, , | |
4373 "-*- texinfo -*-\n\ | |
4374 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ | |
6945 | 4375 Undocumented internal function.\n\ |
6406 | 4376 @end deftypefn") |
4377 { | |
4378 GO_BODY (image); | |
4379 } | |
4380 | |
4381 DEFUN (__go_surface__, args, , | |
4382 "-*- texinfo -*-\n\ | |
4383 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ | |
6945 | 4384 Undocumented internal function.\n\ |
6406 | 4385 @end deftypefn") |
4386 { | |
4387 GO_BODY (surface); | |
4388 } | |
4389 | |
6807 | 4390 DEFUN (__go_patch__, args, , |
4391 "-*- texinfo -*-\n\ | |
4392 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ | |
6945 | 4393 Undocumented internal function.\n\ |
6807 | 4394 @end deftypefn") |
4395 { | |
4396 GO_BODY (patch); | |
4397 } | |
4398 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4399 DEFUN (__go_hggroup__, args, , |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4400 "-*- texinfo -*-\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4401 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4402 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4403 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4404 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4405 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4406 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
4407 |
6406 | 4408 DEFUN (__go_delete__, args, , |
4409 "-*- texinfo -*-\n\ | |
4410 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ | |
6945 | 4411 Undocumented internal function.\n\ |
6406 | 4412 @end deftypefn") |
4413 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4414 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4415 |
6406 | 4416 octave_value_list retval; |
4417 | |
4418 if (args.length () == 1) | |
4419 { | |
4420 graphics_handle h = octave_NaN; | |
4421 | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4422 const NDArray vals = args (0).array_value (); |
6406 | 4423 |
4424 if (! error_state) | |
4425 { | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4426 for (octave_idx_type i = 0; i < vals.numel (); i++) |
6406 | 4427 { |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4428 h = gh_manager::lookup (vals.elem (i)); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4429 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4430 if (h.ok ()) |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4431 { |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4432 graphics_object obj = gh_manager::get_object (h); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4433 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4434 graphics_handle parent_h = obj.get_parent (); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4435 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4436 graphics_object parent_obj = |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4437 gh_manager::get_object (parent_h); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4438 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4439 // NOTE: free the handle before removing it from its parent's |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4440 // children, such that the object's state is correct |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4441 // when the deletefcn callback is executed |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4442 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4443 gh_manager::free (h); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4444 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4445 parent_obj.remove_child (h); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4446 |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4447 Vdrawnow_requested = true; |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4448 } |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4449 else |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4450 { |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4451 error ("delete: invalid graphics object (= %g)", |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4452 vals.elem (i)); |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4453 break; |
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
4454 } |
6406 | 4455 } |
4456 } | |
4457 else | |
4458 error ("delete: invalid graphics object"); | |
4459 } | |
4460 else | |
4461 print_usage (); | |
4462 | |
4463 return retval; | |
4464 } | |
4465 | |
4466 DEFUN (__go_axes_init__, args, , | |
4467 "-*- texinfo -*-\n\ | |
4468 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ | |
6945 | 4469 Undocumented internal function.\n\ |
6406 | 4470 @end deftypefn") |
4471 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4472 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4473 |
6406 | 4474 octave_value retval; |
4475 | |
4476 int nargin = args.length (); | |
4477 | |
4478 std::string mode = ""; | |
4479 | |
4480 if (nargin == 2) | |
4481 { | |
4482 mode = args(1).string_value (); | |
4483 | |
4484 if (error_state) | |
4485 return retval; | |
4486 } | |
4487 | |
4488 if (nargin == 1 || nargin == 2) | |
4489 { | |
4490 graphics_handle h = octave_NaN; | |
4491 | |
4492 double val = args(0).double_value (); | |
4493 | |
4494 if (! error_state) | |
4495 { | |
4496 h = gh_manager::lookup (val); | |
4497 | |
7056 | 4498 if (h.ok ()) |
6406 | 4499 { |
4500 graphics_object obj = gh_manager::get_object (h); | |
4501 | |
4502 obj.set_defaults (mode); | |
4503 } | |
4504 else | |
4505 error ("__go_axes_init__: invalid graphics object (= %g)", val); | |
4506 } | |
4507 else | |
4508 error ("__go_axes_init__: invalid graphics object"); | |
4509 } | |
4510 else | |
4511 print_usage (); | |
4512 | |
4513 return retval; | |
4514 } | |
4515 | |
4516 DEFUN (__go_handles__, , , | |
4517 "-*- texinfo -*-\n\ | |
4518 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ | |
6945 | 4519 Undocumented internal function.\n\ |
6406 | 4520 @end deftypefn") |
4521 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4522 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4523 |
6425 | 4524 return octave_value (gh_manager::handle_list ()); |
4525 } | |
4526 | |
4527 DEFUN (__go_figure_handles__, , , | |
4528 "-*- texinfo -*-\n\ | |
4529 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ | |
6945 | 4530 Undocumented internal function.\n\ |
6425 | 4531 @end deftypefn") |
4532 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4533 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4534 |
6425 | 4535 return octave_value (gh_manager::figure_handle_list ()); |
6406 | 4536 } |
4537 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4538 DEFUN (__go_execute_callback__, args, , |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4539 "-*- texinfo -*-\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4540 @deftypefn {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name})\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4541 @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
|
4542 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4543 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4544 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4545 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4546 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4547 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4548 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4549 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4550 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4551 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4552 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4553 if (! error_state) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4554 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4555 graphics_handle h = gh_manager::lookup (val); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4556 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4557 if (h.ok ()) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4558 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4559 std::string name = args(1).string_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4560 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4561 if (! error_state) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4562 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4563 if (nargin == 2) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4564 gh_manager::execute_callback (h, name); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4565 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4566 gh_manager::execute_callback (h, name, args(2)); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4567 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4568 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4569 error ("__go_execute_callback__: invalid callback name"); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4570 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4571 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4572 error ("__go_execute_callback__: invalid graphics object (= %g)", |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4573 val); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4574 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4575 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4576 error ("__go_execute_callback__: invalid graphics object"); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4577 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4578 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4579 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4580 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4581 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4582 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
4583 |
7924 | 4584 DEFUN (available_backends, , , |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4585 "-*- texinfo -*-\n\ |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4586 @deftypefn {Built-in Function} {} available_backends ()\n\ |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4587 Returns resgistered graphics backends.\n\ |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4588 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4589 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4590 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4591 |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4592 return octave_value (graphics_backend::available_backends_list ()); |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4593 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
4594 |
7409 | 4595 static void |
4596 clear_drawnow_request (void *) | |
4597 { | |
4598 Vdrawnow_requested = false; | |
4599 } | |
4600 | |
7408 | 4601 DEFUN (drawnow, args, , |
4602 "-*- texinfo -*-\n\ | |
4603 @deftypefn {Built-in Function} {} __go_drawnow__ ()\n\ | |
4604 @deftypefnx {Built-in Function} {} __go_drawnow__ (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\ | |
4605 Undocumented internal function.\n\ | |
4606 @end deftypefn") | |
4607 { | |
4608 static int drawnow_executing = 0; | |
4609 static bool __go_close_all_registered__ = false; | |
4610 | |
4611 octave_value retval; | |
4612 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4613 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4614 |
7409 | 4615 unwind_protect::begin_frame ("Fdrawnow"); |
4616 unwind_protect::add (clear_drawnow_request); | |
4617 | |
4618 unwind_protect_int (drawnow_executing); | |
4619 | |
4620 if (++drawnow_executing <= 1) | |
7408 | 4621 { |
7409 | 4622 if (! __go_close_all_registered__) |
4623 { | |
4624 octave_add_atexit_function ("__go_close_all__"); | |
4625 | |
4626 __go_close_all_registered__ = true; | |
4627 } | |
4628 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4629 if (args.length () == 0 || args.length () == 1) |
7408 | 4630 { |
7409 | 4631 Matrix hlist = gh_manager::figure_handle_list (); |
4632 | |
4633 for (int i = 0; ! error_state && i < hlist.length (); i++) | |
7408 | 4634 { |
7409 | 4635 graphics_handle h = gh_manager::lookup (hlist(i)); |
4636 | |
4637 if (h.ok () && h != 0) | |
7408 | 4638 { |
7409 | 4639 graphics_object go = gh_manager::get_object (h); |
4640 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ()); | |
4641 | |
4642 if (fprops.is_modified ()) | |
7408 | 4643 { |
7409 | 4644 if (fprops.is_visible ()) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4645 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4646 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4647 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4648 fprops.get_backend ().redraw_figure (go); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4649 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4650 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4651 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4652 |
7409 | 4653 fprops.set_modified (false); |
7408 | 4654 } |
4655 } | |
4656 } | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4657 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4658 bool do_events = true; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4659 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4660 if (args.length () == 1) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4661 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4662 caseless_str val (args(0).string_value ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4663 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4664 if (! error_state && val.compare ("expose")) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4665 do_events = false; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4666 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4667 error ("drawnow: invalid argument, expected `expose' as argument"); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4668 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4669 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4670 if (do_events) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4671 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4672 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4673 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4674 gh_manager::process_events (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4675 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4676 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4677 } |
7408 | 4678 } |
7409 | 4679 else if (args.length () >= 2 && args.length () <= 4) |
7408 | 4680 { |
7409 | 4681 std::string term, file, debug_file; |
4682 bool mono; | |
4683 | |
4684 term = args(0).string_value (); | |
7408 | 4685 |
4686 if (! error_state) | |
4687 { | |
7409 | 4688 file = args(1).string_value (); |
7408 | 4689 |
4690 if (! error_state) | |
4691 { | |
8007
a2ab20ba78f7
make file_ops a proper singleton class
John W. Eaton <jwe@octave.org>
parents:
7967
diff
changeset
|
4692 size_t pos = file.find_last_of (file_ops::dir_sep_chars ()); |
7409 | 4693 |
8021 | 4694 if (pos != std::string::npos) |
7409 | 4695 { |
4696 file_stat fs (file.substr (0, pos)); | |
4697 | |
4698 if (! (fs && fs.is_dir ())) | |
4699 error ("drawnow: nonexistent directory `%s'", | |
4700 file.substr (0, pos).c_str ()); | |
4701 } | |
4702 | |
4703 mono = (args.length () >= 3 ? args(2).bool_value () : false); | |
7408 | 4704 |
4705 if (! error_state) | |
4706 { | |
7409 | 4707 debug_file = (args.length () > 3 ? args(3).string_value () |
4708 : ""); | |
4709 | |
4710 if (! error_state) | |
7408 | 4711 { |
7409 | 4712 graphics_handle h = gcf (); |
4713 | |
4714 if (h.ok ()) | |
4715 { | |
4716 graphics_object go = gh_manager::get_object (h); | |
4717 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4718 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4719 |
7419 | 4720 go.get_backend () |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
4721 .print_figure (go, term, file, mono, debug_file); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4722 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4723 gh_manager::lock (); |
7409 | 4724 } |
4725 else | |
4726 error ("drawnow: nothing to draw"); | |
7408 | 4727 } |
4728 else | |
7409 | 4729 error ("drawnow: invalid debug_file, expected a string value"); |
7408 | 4730 } |
4731 else | |
7409 | 4732 error ("drawnow: invalid colormode, expected a boolean value"); |
7408 | 4733 } |
4734 else | |
7409 | 4735 error ("drawnow: invalid file, expected a string value"); |
7408 | 4736 } |
4737 else | |
7409 | 4738 error ("drawnow: invalid terminal, expected a string value"); |
7408 | 4739 } |
4740 else | |
7409 | 4741 print_usage (); |
7408 | 4742 } |
7409 | 4743 |
4744 unwind_protect::run_frame ("Fdrawnow"); | |
7408 | 4745 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4746 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4747 |
7408 | 4748 return retval; |
4749 } | |
4750 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4751 DEFUN (addlistener, args, , |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4752 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4753 @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
|
4754 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4755 object @var{h}. Property listeners are executed (in order of registration)\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4756 when the property is set. The new value is already available when the\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4757 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4758 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4759 @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
|
4760 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4761 @var{fcn} can be a function handle, a string or a cell array whose first\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4762 element is a function handle. If @var{fcn} is a function handle, the\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4763 corresponding function should accept at least 2 arguments, that will be\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4764 set to the object handle and the empty matrix respectively. If @var{fcn}\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4765 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4766 array, the first element must be a function handle with the same signature\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4767 as described above. The next elements of the cell array are passed\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4768 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
|
4769 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4770 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4771 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4772 @example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4773 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
|
4774 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
|
4775 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4776 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4777 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4778 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4779 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4780 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4781 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4782 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4783 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4784 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4785 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4786 if (args.length () == 3) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4787 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4788 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4789 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4790 if (! error_state) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4791 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4792 std::string pname = args(1).string_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4793 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4794 if (! error_state) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4795 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4796 graphics_handle gh = gh_manager::lookup (h); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4797 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4798 if (gh.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4799 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4800 graphics_object go = gh_manager::get_object (gh); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4801 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4802 go.add_property_listener (pname, args(2), POSTSET); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4803 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4804 else |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4805 error ("addlistener: invalid graphics object (= %g)", |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4806 h); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4807 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4808 else |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4809 error ("addlistener: invalid property name, expected a string value"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4810 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4811 else |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
4812 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4813 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4814 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4815 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4816 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4817 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4818 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
4819 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4820 DEFUN (addproperty, args, , |
7869 | 4821 "-*- texinfo -*-\n\ |
4822 @deftypefn {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
|
4823 Create a new property named @var{name} in graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4824 @var{type} determines the type of the property to create. @var{args}\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4825 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
|
4826 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
|
4827 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4828 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4829 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4830 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4831 @item string\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4832 A string property. @var{arg} contains the default string value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4833 @item any\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4834 An un-typed property. This kind of property can hold any octave\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4835 value. @var{args} contains the default value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4836 @item radio\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4837 A string property with a limited set of accepted values. The first\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4838 argument must be a string with all accepted values separated by\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4839 a vertical bar ('|'). The default value can be marked by enclosing\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4840 it with a '@{' '@}' pair. The default value may also be given as\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4841 an optional second string argument.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4842 @item boolean\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4843 A boolean property. This property type is equivalent to a radio\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4844 property with \"on|off\" as accepted values. @var{arg} contains\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4845 the default property value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4846 @item double\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4847 A scalar double property. @var{arg} contains the default value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4848 @item handle\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4849 A handle property. This kind of property holds the handle of a\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4850 graphics object. @var{arg} contains the default handle value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4851 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
|
4852 the empty matrix.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4853 @item data\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4854 A data (matrix) property. @var{arg} contains the default data\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4855 value. When no default value is given, the data is initialized to\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4856 the empty matrix.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4857 @item color\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4858 A color property. @var{arg} contains the default color value.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4859 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
|
4860 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
|
4861 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
|
4862 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4863 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4864 @var{type} may also be the concatenation of a core object type and\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4865 a valid property name for that object type. The property created\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4866 then has the same characteristics as the referenced property (type,\n\ |
7869 | 4867 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
|
4868 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4869 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4870 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4871 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4872 @example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4873 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4874 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
|
4875 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4876 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4877 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4878 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4879 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4880 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4881 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4882 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4883 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4884 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4885 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4886 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4887 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4888 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4889 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4890 double h = args(1).double_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4891 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4892 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4893 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4894 graphics_handle gh = gh_manager::lookup (h); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4895 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4896 if (gh.ok ()) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4897 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4898 graphics_object go = gh_manager::get_object (gh); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4899 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4900 std::string type = args(2).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4901 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4902 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4903 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4904 if (! go.get_properties ().has_property (name)) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4905 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4906 property p = property::create (name, gh, type, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4907 args.splice (0, 3)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4908 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4909 if (! error_state) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4910 go.get_properties ().insert_property (name, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4911 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4912 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4913 error ("addproperty: a `%s' property already exists in the graphics object", |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4914 name.c_str ()); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4915 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4916 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4917 error ("addproperty: invalid property type, expected a string value"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4918 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4919 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4920 error ("addproperty: invalid graphics object (= %g)", h); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4921 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4922 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4923 error ("addproperty: invalid handle value"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4924 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4925 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4926 error ("addproperty: invalid property name, expected a string value"); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4927 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4928 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4929 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4930 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4931 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4932 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
4933 |
6595 | 4934 octave_value |
7447 | 4935 get_property_from_handle (double handle, const std::string& property, |
4936 const std::string& func) | |
6595 | 4937 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4938 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4939 |
6595 | 4940 graphics_object obj = gh_manager::get_object (handle); |
4941 octave_value retval; | |
4942 | |
4943 if (obj) | |
4944 { | |
7189 | 4945 caseless_str p = std::string (property); |
6595 | 4946 retval = obj.get (p); |
4947 } | |
4948 else | |
4949 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
4950 | |
4951 return retval; | |
4952 } | |
4953 | |
4954 bool | |
7447 | 4955 set_property_in_handle (double handle, const std::string& property, |
4956 const octave_value& arg, const std::string& func) | |
6595 | 4957 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4958 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
4959 |
6595 | 4960 graphics_object obj = gh_manager::get_object (handle); |
4961 int ret = false; | |
4962 | |
4963 if (obj) | |
4964 { | |
7189 | 4965 caseless_str p = std::string (property); |
6595 | 4966 obj.set (p, arg); |
4967 if (!error_state) | |
4968 ret = true; | |
4969 } | |
4970 else | |
4971 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
4972 | |
4973 return ret; | |
4974 } | |
4975 | |
6406 | 4976 /* |
4977 ;;; Local Variables: *** | |
4978 ;;; mode: C++ *** | |
4979 ;;; End: *** | |
4980 */ |