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 |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
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 |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <cctype> |
|
29 |
|
30 #include <algorithm> |
|
31 #include <list> |
|
32 #include <map> |
|
33 #include <set> |
|
34 #include <string> |
|
35 |
6705
|
36 #include "defun.h" |
|
37 #include "error.h" |
6595
|
38 #include "graphics.h" |
6705
|
39 #include "ov.h" |
|
40 #include "oct-obj.h" |
|
41 #include "oct-map.h" |
|
42 #include "ov-fcn-handle.h" |
|
43 #include "parse.h" |
6595
|
44 |
6406
|
45 static void |
|
46 gripe_set_invalid (const std::string& pname) |
|
47 { |
|
48 error ("set: invalid value for %s property", pname.c_str ()); |
|
49 } |
|
50 |
|
51 static octave_value |
|
52 nan_to_empty (double val) |
|
53 { |
|
54 return xisnan (val) ? octave_value (Matrix ()) : octave_value (val); |
|
55 } |
|
56 |
|
57 static octave_value |
|
58 empty_to_nan (const octave_value& val) |
|
59 { |
|
60 return val.is_empty () ? octave_value (octave_NaN) : val; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------- |
|
64 |
6705
|
65 radio_values::radio_values (const std::string& opt_string) |
6406
|
66 { |
6705
|
67 size_t beg = 0; |
|
68 size_t len = opt_string.length (); |
|
69 bool done = len == 0; |
6681
|
70 |
6705
|
71 while (! done) |
|
72 { |
|
73 size_t end = opt_string.find ('|', beg); |
6681
|
74 |
6705
|
75 if (end == std::string::npos) |
|
76 { |
|
77 end = len; |
|
78 done = true; |
|
79 } |
6681
|
80 |
6705
|
81 std::string t = opt_string.substr (beg, end-beg); |
6681
|
82 |
6705
|
83 // Might want more error checking here... |
|
84 if (t[0] == '{') |
|
85 { |
|
86 t = t.substr (1, t.length () - 2); |
|
87 default_val = t; |
|
88 } |
|
89 else if (beg == 0) // ensure default value |
|
90 default_val = t; |
6681
|
91 |
6705
|
92 possible_vals.insert (t); |
6681
|
93 |
6705
|
94 beg = end + 1; |
|
95 } |
|
96 } |
6681
|
97 |
6705
|
98 bool |
6761
|
99 color_values::str2rgb (std::string str) |
6681
|
100 { |
6705
|
101 double tmp_rgb[3] = {0, 0, 0}; |
|
102 bool retval = true; |
6761
|
103 unsigned int len = str.length(); |
6681
|
104 |
6761
|
105 if (str.compare(0, len, "blue", 0, len) == 0) |
|
106 tmp_rgb[2] = 1; |
|
107 else if (str.compare(0, len, "black", 0, len) == 0 || str.compare(0, len, "w", 0, len) == 0) |
|
108 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
|
109 else if (str.compare(0, len, "red", 0, len) == 0) |
|
110 tmp_rgb[0] = 1; |
|
111 else if (str.compare(0, len, "green", 0, len) == 0) |
|
112 tmp_rgb[1] = 1; |
|
113 else if (str.compare(0, len, "yellow", 0, len) == 0) |
|
114 tmp_rgb[0] = tmp_rgb[1] = 1; |
|
115 else if (str.compare(0, len, "magenta", 0, len) == 0) |
|
116 tmp_rgb[0] = tmp_rgb[2] = 1; |
|
117 else if (str.compare(0, len, "cyan", 0, len) == 0) |
|
118 tmp_rgb[1] = tmp_rgb[2] = 1; |
|
119 else if (str.compare(0, len, "white", 0, len) == 0) |
|
120 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; |
|
121 else |
|
122 retval = false; |
6406
|
123 |
6705
|
124 if (retval) |
|
125 { |
|
126 for (int i = 0; i < 3; i++) |
|
127 xrgb[i] = tmp_rgb[i]; |
|
128 } |
6563
|
129 |
6705
|
130 return retval; |
|
131 } |
6681
|
132 |
6705
|
133 color_property::color_property (const octave_value& val) |
|
134 : radio_val (), current_val () |
|
135 { |
|
136 // FIXME -- need some error checking here. |
6681
|
137 |
6705
|
138 if (val.is_string ()) |
|
139 { |
|
140 std::string s = val.string_value (); |
6681
|
141 |
6705
|
142 if (! s.empty ()) |
|
143 { |
6761
|
144 color_values col (s); |
6705
|
145 if (! error_state) |
|
146 { |
|
147 color_val = col; |
|
148 current_type = color_t; |
|
149 } |
|
150 } |
|
151 else |
|
152 error ("invalid color specification"); |
|
153 } |
|
154 else if (val.is_real_matrix ()) |
|
155 { |
|
156 Matrix m = val.matrix_value (); |
6563
|
157 |
6705
|
158 if (m.numel () == 3) |
|
159 { |
|
160 color_values col (m (0), m (1), m(2)); |
|
161 if (! error_state) |
|
162 { |
|
163 color_val = col; |
|
164 current_type = color_t; |
|
165 } |
|
166 } |
|
167 else |
|
168 error ("invalid color specification"); |
|
169 } |
|
170 else |
|
171 error ("invalid color specification"); |
|
172 } |
6406
|
173 |
6790
|
174 // We also provide this assignment operator so that assignment from an |
|
175 // octave_value object can happen without wiping out list of possible |
|
176 // radio_values set in color_property constructor. |
|
177 |
|
178 color_property& |
|
179 color_property::operator = (const octave_value& val) |
|
180 { |
|
181 if (val.is_string ()) |
|
182 { |
|
183 std::string s = val.string_value (); |
|
184 |
|
185 if (! s.empty ()) |
|
186 { |
|
187 if (radio_val.validate (s)) |
|
188 { |
|
189 current_val = s; |
|
190 current_type = radio_t; |
|
191 } |
|
192 else |
|
193 { |
|
194 color_values col (s); |
|
195 if (! error_state) |
|
196 { |
|
197 color_val = col; |
|
198 current_type = color_t; |
|
199 } |
|
200 else |
|
201 error ("invalid color specification"); |
|
202 } |
|
203 } |
|
204 else |
|
205 error ("invalid color specification"); |
|
206 } |
|
207 else if (val.is_real_matrix ()) |
|
208 { |
|
209 Matrix m = val.matrix_value (); |
|
210 |
|
211 if (m.numel () == 3) |
|
212 { |
|
213 color_values col (m (0), m (1), m(2)); |
|
214 if (! error_state) |
|
215 { |
|
216 color_val = col; |
|
217 current_type = color_t; |
|
218 } |
|
219 } |
|
220 else |
|
221 error ("invalid color specification"); |
|
222 } |
|
223 else |
|
224 error ("invalid color specification"); |
|
225 |
|
226 return *this; |
|
227 } |
|
228 |
6681
|
229 |
6705
|
230 void |
|
231 property_list::set (const property_name& name, const octave_value& val) |
6681
|
232 { |
6705
|
233 size_t offset = 0; |
6681
|
234 |
6705
|
235 size_t len = name.length (); |
6681
|
236 |
6705
|
237 if (len > 4) |
|
238 { |
|
239 property_name pfx = name.substr (0, 4); |
6681
|
240 |
6705
|
241 if (pfx.compare ("axes") || pfx.compare ("line") |
|
242 || pfx.compare ("text")) |
|
243 offset = 4; |
|
244 else if (len > 5) |
|
245 { |
|
246 pfx = name.substr (0, 5); |
6681
|
247 |
6807
|
248 if (pfx.compare ("image") || pfx.compare ("patch")) |
6705
|
249 offset = 5; |
|
250 else if (len > 6) |
|
251 { |
|
252 pfx = name.substr (0, 6); |
6681
|
253 |
6705
|
254 if (pfx.compare ("figure")) |
|
255 offset = 6; |
|
256 else if (len > 7) |
|
257 { |
|
258 pfx = name.substr (0, 7); |
6681
|
259 |
6705
|
260 if (pfx.compare ("surface")) |
|
261 offset = 7; |
|
262 } |
|
263 } |
|
264 } |
6681
|
265 |
6705
|
266 if (offset > 0) |
|
267 { |
|
268 // FIXME -- should we validate property names and values here? |
6406
|
269 |
6705
|
270 std::string pname = name.substr (offset); |
6406
|
271 |
6705
|
272 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
|
273 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
6406
|
274 |
6705
|
275 bool remove = false; |
|
276 if (val.is_string ()) |
|
277 { |
|
278 property_name tval = val.string_value (); |
6406
|
279 |
6705
|
280 remove = tval.compare ("remove"); |
|
281 } |
6406
|
282 |
6705
|
283 pval_map_type& pval_map = plist_map[pfx]; |
6406
|
284 |
6705
|
285 if (remove) |
|
286 { |
|
287 pval_map_iterator p = pval_map.find (pname); |
6406
|
288 |
6705
|
289 if (p != pval_map.end ()) |
|
290 pval_map.erase (p); |
|
291 } |
|
292 else |
|
293 pval_map[pname] = val; |
|
294 } |
|
295 } |
6406
|
296 |
6705
|
297 if (offset == 0) |
|
298 error ("invalid default property specification"); |
|
299 } |
6406
|
300 |
6705
|
301 octave_value |
|
302 property_list::lookup (const property_name& name) const |
|
303 { |
|
304 octave_value retval; |
6406
|
305 |
6705
|
306 size_t offset = 0; |
6406
|
307 |
6705
|
308 size_t len = name.length (); |
6406
|
309 |
6705
|
310 if (len > 4) |
|
311 { |
|
312 property_name pfx = name.substr (0, 4); |
6406
|
313 |
6705
|
314 if (pfx.compare ("axes") || pfx.compare ("line") |
|
315 || pfx.compare ("text")) |
|
316 offset = 4; |
|
317 else if (len > 5) |
|
318 { |
|
319 pfx = name.substr (0, 5); |
6406
|
320 |
6807
|
321 if (pfx.compare ("image") || pfx.compare ("patch")) |
6705
|
322 offset = 5; |
|
323 else if (len > 6) |
|
324 { |
|
325 pfx = name.substr (0, 6); |
6406
|
326 |
6705
|
327 if (pfx.compare ("figure")) |
|
328 offset = 6; |
|
329 else if (len > 7) |
|
330 { |
|
331 pfx = name.substr (0, 7); |
6406
|
332 |
6705
|
333 if (pfx.compare ("surface")) |
|
334 offset = 7; |
|
335 } |
|
336 } |
|
337 } |
6406
|
338 |
6705
|
339 if (offset > 0) |
|
340 { |
|
341 std::string pname = name.substr (offset); |
6406
|
342 |
6705
|
343 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
|
344 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
6406
|
345 |
6705
|
346 plist_map_const_iterator p = find (pfx); |
6432
|
347 |
6705
|
348 if (p != end ()) |
|
349 { |
|
350 const pval_map_type& pval_map = p->second; |
6406
|
351 |
6705
|
352 pval_map_const_iterator q = pval_map.find (pname); |
6406
|
353 |
6705
|
354 if (q != pval_map.end ()) |
|
355 retval = q->second; |
|
356 } |
|
357 } |
|
358 } |
6406
|
359 |
6705
|
360 return retval; |
|
361 } |
6406
|
362 |
6705
|
363 Octave_map |
|
364 property_list::as_struct (const std::string& prefix_arg) const |
|
365 { |
|
366 Octave_map m; |
6406
|
367 |
6705
|
368 for (plist_map_const_iterator p = begin (); p != end (); p++) |
|
369 { |
|
370 std::string prefix = prefix_arg + p->first; |
6406
|
371 |
6705
|
372 const pval_map_type pval_map = p->second; |
6406
|
373 |
6705
|
374 for (pval_map_const_iterator q = pval_map.begin (); |
|
375 q != pval_map.end (); |
|
376 q++) |
|
377 m.assign (prefix + q->first, q->second); |
|
378 } |
6406
|
379 |
6705
|
380 return m; |
|
381 } |
6432
|
382 |
6705
|
383 void |
|
384 graphics_object::set (const octave_value_list& args) |
|
385 { |
|
386 int nargin = args.length (); |
6406
|
387 |
6705
|
388 if (nargin == 0) |
|
389 rep->defaults (); |
|
390 else if (nargin % 2 == 0) |
|
391 { |
|
392 for (int i = 0; i < nargin; i += 2) |
|
393 { |
|
394 property_name name = args(i).string_value (); |
6406
|
395 |
6705
|
396 if (! error_state) |
|
397 { |
|
398 octave_value val = args(i+1); |
6406
|
399 |
6705
|
400 if (val.is_string ()) |
|
401 { |
|
402 property_name tval = val.string_value (); |
6406
|
403 |
6705
|
404 if (tval.compare ("default")) |
|
405 val = get_default (name); |
|
406 else if (tval.compare ("factory")) |
|
407 val = get_factory_default (name); |
|
408 } |
6406
|
409 |
6705
|
410 if (error_state) |
|
411 break; |
6406
|
412 |
6705
|
413 rep->set (name, val); |
|
414 } |
|
415 else |
|
416 error ("set: expecting argument %d to be a property name", i); |
|
417 } |
|
418 } |
|
419 else |
|
420 error ("set: invalid number of arguments"); |
|
421 } |
6406
|
422 |
|
423 |
6705
|
424 graphics_handle |
|
425 gh_manager::get_handle (const std::string& go_name) |
|
426 { |
|
427 graphics_handle retval; |
6406
|
428 |
6705
|
429 if (go_name == "figure") |
|
430 { |
|
431 // We always want the lowest unused figure number. |
6406
|
432 |
6705
|
433 retval = 1; |
6425
|
434 |
6705
|
435 while (handle_map.find (retval) != handle_map.end ()) |
|
436 retval++; |
|
437 } |
|
438 else |
|
439 { |
|
440 free_list_iterator p = handle_free_list.begin (); |
6406
|
441 |
6705
|
442 if (p != handle_free_list.end ()) |
|
443 { |
|
444 retval = *p; |
|
445 handle_free_list.erase (p); |
|
446 } |
|
447 else |
|
448 retval = next_handle--; |
|
449 } |
6406
|
450 |
6705
|
451 return retval; |
|
452 } |
6406
|
453 |
6705
|
454 void |
|
455 gh_manager::do_free (const graphics_handle& h) |
|
456 { |
|
457 if (h != 0) |
|
458 { |
|
459 iterator p = handle_map.find (h); |
6406
|
460 |
6705
|
461 if (p != handle_map.end ()) |
|
462 { |
|
463 handle_map.erase (p); |
6406
|
464 |
6705
|
465 if (h < 0) |
|
466 handle_free_list.insert (h); |
|
467 } |
|
468 else |
|
469 error ("graphics_handle::free: invalid object %g", h); |
|
470 } |
|
471 else |
|
472 error ("graphics_handle::free: can't delete root figure"); |
|
473 } |
6406
|
474 |
|
475 |
|
476 gh_manager *gh_manager::instance = 0; |
|
477 |
|
478 static void |
|
479 xset (const graphics_handle& h, const property_name& name, |
|
480 const octave_value& val) |
|
481 { |
|
482 graphics_object obj = gh_manager::get_object (h); |
|
483 obj.set (name, val); |
|
484 } |
|
485 |
|
486 static void |
|
487 xset (const graphics_handle& h, const octave_value_list& args) |
|
488 { |
|
489 if (args.length () > 0) |
|
490 { |
|
491 graphics_object obj = gh_manager::get_object (h); |
|
492 obj.set (args); |
|
493 } |
|
494 } |
|
495 |
|
496 |
|
497 static octave_value |
|
498 xget (const graphics_handle& h, const property_name& name) |
|
499 { |
|
500 graphics_object obj = gh_manager::get_object (h); |
|
501 return obj.get (name); |
|
502 } |
|
503 |
|
504 static graphics_handle |
|
505 reparent (const octave_value& ov, const std::string& who, |
|
506 const std::string& property, const graphics_handle& new_parent, |
|
507 bool adopt = true) |
|
508 { |
|
509 graphics_handle h = octave_NaN; |
|
510 |
|
511 double val = ov.double_value (); |
|
512 |
|
513 if (! error_state) |
|
514 { |
|
515 h = gh_manager::lookup (val); |
|
516 |
|
517 if (! xisnan (h)) |
|
518 { |
|
519 graphics_object obj = gh_manager::get_object (h); |
|
520 |
|
521 graphics_handle parent_h = obj.get_parent (); |
|
522 |
|
523 graphics_object parent_obj = gh_manager::get_object (parent_h); |
|
524 |
|
525 parent_obj.remove_child (h); |
|
526 |
|
527 if (adopt) |
|
528 obj.set ("parent", new_parent); |
|
529 else |
|
530 obj.reparent (new_parent); |
|
531 } |
|
532 else |
|
533 error ("%s: invalid graphics handle (= %g) for %s", |
|
534 who.c_str (), val, property.c_str ()); |
|
535 } |
|
536 else |
|
537 error ("%s: expecting %s to be a graphics handle", |
|
538 who.c_str (), property.c_str ()); |
|
539 |
|
540 return h; |
|
541 } |
|
542 |
|
543 // This function is NOT equivalent to the scripting language function gcf. |
|
544 graphics_handle |
|
545 gcf (void) |
|
546 { |
|
547 octave_value val = xget (0, "currentfigure"); |
|
548 |
|
549 return val.is_empty () ? octave_NaN : val.double_value (); |
|
550 } |
|
551 |
|
552 // This function is NOT equivalent to the scripting language function gca. |
|
553 graphics_handle |
|
554 gca (void) |
|
555 { |
|
556 octave_value val = xget (gcf (), "currentaxes"); |
|
557 |
|
558 return val.is_empty () ? octave_NaN : val.double_value (); |
|
559 } |
|
560 |
|
561 static void |
|
562 adopt (const graphics_handle& p, const graphics_handle& h) |
|
563 { |
|
564 graphics_object parent_obj = gh_manager::get_object (p); |
|
565 |
|
566 parent_obj.adopt (h); |
|
567 } |
|
568 |
|
569 static bool |
|
570 is_handle (double val) |
|
571 { |
|
572 return ! xisnan (gh_manager::lookup (val)); |
|
573 } |
|
574 |
|
575 static bool |
|
576 is_handle (const octave_value& val) |
|
577 { |
|
578 return val.is_real_type () && is_handle (val.double_value ()); |
|
579 } |
|
580 |
|
581 static bool |
|
582 is_figure (double val) |
|
583 { |
|
584 graphics_object obj = gh_manager::get_object (val); |
|
585 |
|
586 return obj && obj.isa ("figure"); |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------- |
|
590 |
|
591 static int |
|
592 compare (const void *a_arg, const void *b_arg) |
|
593 { |
|
594 double a = *(static_cast<const double *> (a_arg)); |
|
595 double b = *(static_cast<const double *> (b_arg)); |
|
596 |
|
597 return a > b ? 1 : (a < b) ? -1 : 0; |
|
598 } |
|
599 |
|
600 static Matrix |
|
601 maybe_set_children (const Matrix& kids, const octave_value& val) |
|
602 { |
|
603 const Matrix new_kids = val.matrix_value (); |
|
604 |
|
605 bool ok = true; |
|
606 |
|
607 if (! error_state) |
|
608 { |
|
609 if (kids.numel () == new_kids.numel ()) |
|
610 { |
|
611 Matrix t1 = kids; |
|
612 Matrix t2 = new_kids; |
|
613 |
|
614 t1.qsort (compare); |
|
615 t2.qsort (compare); |
|
616 |
|
617 if (t1 != t2) |
|
618 ok = false; |
|
619 } else |
|
620 ok = false; |
|
621 |
|
622 if (! ok) |
|
623 error ("set: new children must be a permutation of existing children"); |
|
624 } |
|
625 else |
|
626 { |
|
627 ok = false; |
|
628 error ("set: expecting children to be array of graphics handles"); |
|
629 } |
|
630 |
|
631 return ok ? new_kids : kids; |
|
632 } |
|
633 |
6705
|
634 void |
|
635 base_properties::set_from_list (base_graphics_object& obj, |
|
636 property_list& defaults) |
6406
|
637 { |
6705
|
638 std::string go_name = graphics_object_name (); |
6406
|
639 |
6705
|
640 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406
|
641 |
6705
|
642 if (p != defaults.end ()) |
|
643 { |
|
644 const property_list::pval_map_type pval_map = p->second; |
6406
|
645 |
6705
|
646 for (property_list::pval_map_const_iterator q = pval_map.begin (); |
|
647 q != pval_map.end (); |
|
648 q++) |
|
649 { |
|
650 std::string pname = q->first; |
6406
|
651 |
6705
|
652 obj.set (pname, q->second); |
6406
|
653 |
6705
|
654 if (error_state) |
|
655 { |
|
656 error ("error setting default property %s", pname.c_str ()); |
|
657 break; |
|
658 } |
|
659 } |
|
660 } |
|
661 } |
6406
|
662 |
6705
|
663 void |
|
664 base_properties::remove_child (const graphics_handle& h) |
6406
|
665 { |
6705
|
666 octave_idx_type k = -1; |
|
667 octave_idx_type n = children.numel (); |
|
668 for (octave_idx_type i = 0; i < n; i++) |
6406
|
669 { |
6705
|
670 if (h == children(i)) |
6406
|
671 { |
6705
|
672 k = i; |
|
673 break; |
6406
|
674 } |
|
675 } |
|
676 |
6705
|
677 if (k >= 0) |
6406
|
678 { |
6705
|
679 Matrix new_kids (1, n-1); |
|
680 octave_idx_type j = 0; |
|
681 for (octave_idx_type i = 0; i < n; i++) |
|
682 { |
|
683 if (i != k) |
|
684 new_kids(j++) = children(i); |
|
685 } |
|
686 children = new_kids; |
6406
|
687 } |
6705
|
688 } |
6406
|
689 |
6705
|
690 void base_properties::set_parent (const octave_value& val) |
|
691 { |
|
692 double tmp = val.double_value (); |
6406
|
693 |
6705
|
694 graphics_handle new_parent = octave_NaN; |
6406
|
695 |
6705
|
696 if (! error_state) |
|
697 { |
|
698 new_parent = gh_manager::lookup (tmp); |
6406
|
699 |
6705
|
700 if (! xisnan (new_parent)) |
|
701 { |
|
702 graphics_object parent_obj = gh_manager::get_object (parent); |
6406
|
703 |
6705
|
704 parent_obj.remove_child (__myhandle__); |
6406
|
705 |
6705
|
706 parent = new_parent; |
6406
|
707 |
6705
|
708 ::adopt (parent, __myhandle__); |
|
709 } |
|
710 else |
|
711 error ("set: invalid graphics handle (= %g) for parent", tmp); |
|
712 } |
|
713 else |
|
714 error ("set: expecting parent to be a graphics handle"); |
|
715 } |
6432
|
716 |
6705
|
717 void |
|
718 root_figure::root_figure_properties::set (const property_name& name, |
|
719 const octave_value& val) |
|
720 { |
|
721 if (name.compare ("currentfigure")) |
|
722 { |
|
723 octave_value tval = empty_to_nan (val); |
6406
|
724 |
6705
|
725 if (is_handle (tval)) |
|
726 { |
|
727 currentfigure = tval.double_value (); |
6406
|
728 |
6705
|
729 gh_manager::push_figure (currentfigure); |
|
730 } |
|
731 else |
|
732 gripe_set_invalid ("currentfigure"); |
|
733 } |
|
734 else if (name.compare ("children")) |
|
735 children = maybe_set_children (children, val); |
|
736 else if (name.compare ("visible")) |
|
737 visible = val; |
|
738 else |
|
739 warning ("set: invalid property `%s'", name.c_str ()); |
|
740 } |
6406
|
741 |
6705
|
742 octave_value root_figure::root_figure_properties::get (void) const |
|
743 { |
|
744 Octave_map m; |
6406
|
745 |
6705
|
746 m.assign ("type", type); |
|
747 m.assign ("currentfigure", nan_to_empty (currentfigure)); |
|
748 m.assign ("children", children); |
|
749 m.assign ("visible", visible); |
6406
|
750 |
6705
|
751 return m; |
|
752 } |
6406
|
753 |
6705
|
754 octave_value |
|
755 root_figure::root_figure_properties::get (const property_name& name) const |
|
756 { |
|
757 octave_value retval; |
6406
|
758 |
6705
|
759 if (name.compare ("type")) |
|
760 retval = type; |
|
761 else if (name.compare ("currentfigure")) |
|
762 retval = nan_to_empty (currentfigure); |
|
763 else if (name.compare ("children")) |
|
764 retval = children; |
|
765 else if (name.compare ("visible")) |
|
766 retval = visible; |
|
767 else |
|
768 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
769 |
6705
|
770 return retval; |
|
771 } |
6406
|
772 |
|
773 property_list |
|
774 root_figure::factory_properties = root_figure::init_factory_properties (); |
|
775 |
|
776 std::string root_figure::root_figure_properties::go_name ("root figure"); |
|
777 |
|
778 // --------------------------------------------------------------------- |
|
779 |
6705
|
780 figure::figure_properties::figure_properties (const graphics_handle& mh, |
|
781 const graphics_handle& p) |
|
782 : base_properties (go_name, mh, p), |
|
783 __plot_stream__ (Matrix ()), |
|
784 nextplot ("replace"), |
|
785 closerequestfcn (make_fcn_handle ("closereq")), |
|
786 currentaxes (octave_NaN), |
|
787 colormap (), |
|
788 visible ("on"), |
|
789 paperorientation ("portrait") |
|
790 { } |
|
791 |
|
792 void |
|
793 figure::figure_properties::set (const property_name& name, |
|
794 const octave_value& val) |
6406
|
795 { |
6705
|
796 bool modified = true; |
6406
|
797 |
6705
|
798 if (name.compare ("children")) |
|
799 children = maybe_set_children (children, val); |
|
800 else if (name.compare ("__modified__")) |
|
801 { |
|
802 __modified__ = val.bool_value (); |
|
803 modified = false; |
|
804 } |
|
805 else if (name.compare ("__plot_stream__")) |
|
806 __plot_stream__ = val; |
|
807 else if (name.compare ("nextplot")) |
|
808 nextplot = val; |
|
809 else if (name.compare ("closerequestfcn")) |
|
810 closerequestfcn = val; |
|
811 else if (name.compare ("currentaxes")) |
6406
|
812 { |
6705
|
813 octave_value tval = empty_to_nan (val); |
6432
|
814 |
6705
|
815 if (is_handle (tval)) |
|
816 currentaxes = tval.double_value (); |
|
817 else |
|
818 gripe_set_invalid ("currentaxes"); |
|
819 } |
|
820 else if (name.compare ("colormap")) |
|
821 colormap = colormap_property (val); |
|
822 else if (name.compare ("visible")) |
|
823 { |
|
824 std::string s = val.string_value (); |
|
825 |
|
826 if (! error_state) |
6432
|
827 { |
6705
|
828 if (s == "on") |
|
829 xset (0, "currentfigure", __myhandle__); |
6425
|
830 |
6705
|
831 visible = val; |
6425
|
832 } |
6406
|
833 } |
6705
|
834 else if (name.compare ("paperorientation")) |
|
835 paperorientation = val; |
|
836 else |
6406
|
837 { |
6705
|
838 modified = false; |
|
839 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
840 } |
|
841 |
6705
|
842 if (modified) |
|
843 mark_modified (); |
|
844 } |
|
845 |
|
846 octave_value |
|
847 figure::figure_properties::get (void) const |
|
848 { |
|
849 Octave_map m; |
6406
|
850 |
6705
|
851 m.assign ("type", type); |
|
852 m.assign ("parent", parent); |
|
853 m.assign ("children", children); |
|
854 m.assign ("__modified__", __modified__); |
|
855 m.assign ("__plot_stream__", __plot_stream__); |
|
856 m.assign ("nextplot", nextplot); |
|
857 m.assign ("closerequestfcn", closerequestfcn); |
|
858 m.assign ("currentaxes", nan_to_empty (currentaxes)); |
|
859 m.assign ("colormap", colormap); |
|
860 m.assign ("visible", visible); |
|
861 m.assign ("paperorientation", paperorientation); |
|
862 |
|
863 return m; |
|
864 } |
|
865 |
|
866 octave_value |
|
867 figure::figure_properties::get (const property_name& name) const |
|
868 { |
|
869 octave_value retval; |
6406
|
870 |
6705
|
871 if (name.compare ("type")) |
|
872 retval = type; |
|
873 else if (name.compare ("parent")) |
|
874 retval = parent; |
|
875 else if (name.compare ("children")) |
|
876 retval = children; |
|
877 else if (name.compare ("__modified__")) |
|
878 retval = __modified__; |
|
879 else if (name.compare ("__plot_stream__")) |
|
880 retval = __plot_stream__; |
|
881 else if (name.compare ("nextplot")) |
|
882 retval = nextplot; |
|
883 else if (name.compare ("closerequestfcn")) |
|
884 retval = closerequestfcn; |
|
885 else if (name.compare ("currentaxes")) |
|
886 retval = nan_to_empty (currentaxes); |
|
887 else if (name.compare ("colormap")) |
|
888 retval = colormap; |
|
889 else if (name.compare ("visible")) |
|
890 retval = visible; |
|
891 else if (name.compare ("paperorientation")) |
|
892 retval = paperorientation; |
|
893 else |
|
894 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
895 |
6705
|
896 return retval; |
|
897 } |
6406
|
898 |
6705
|
899 void figure::figure_properties::close (void) |
|
900 { |
|
901 if (! __plot_stream__.is_empty ()) |
6406
|
902 { |
6705
|
903 octave_value_list args; |
|
904 args(1) = "\nquit;\n"; |
|
905 args(0) = __plot_stream__; |
|
906 feval ("fputs", args); |
|
907 args.resize (1); |
|
908 feval ("fflush", args); |
|
909 feval ("pclose", args); |
6406
|
910 } |
|
911 |
6705
|
912 gh_manager::pop_figure (__myhandle__); |
6406
|
913 |
6705
|
914 xset (0, "currentfigure", gh_manager::current_figure ()); |
|
915 } |
6432
|
916 |
6705
|
917 property_list::pval_map_type figure::figure_properties::factory_defaults (void) |
|
918 { |
|
919 property_list::pval_map_type m; |
6406
|
920 |
6705
|
921 m["nextplot"] = "replace"; |
|
922 // m["closerequestfcn"] = make_fcn_handle ("closereq"); |
|
923 m["colormap"] = colormap_property (); |
|
924 m["visible"] = "on"; |
|
925 m["paperorientation"] = "portrait"; |
6406
|
926 |
6705
|
927 return m; |
|
928 } |
6406
|
929 |
|
930 std::string figure::figure_properties::go_name ("figure"); |
|
931 |
|
932 // --------------------------------------------------------------------- |
|
933 |
6705
|
934 axes::axes_properties::axes_properties (const graphics_handle& mh, |
|
935 const graphics_handle& p) |
|
936 : base_properties (go_name, mh, p), |
|
937 position (Matrix ()), |
|
938 title (octave_NaN), |
|
939 box ("on"), |
|
940 key ("off"), |
|
941 keybox ("off"), |
|
942 keypos (1), |
|
943 dataaspectratio (Matrix (1, 3, 1.0)), |
|
944 dataaspectratiomode ("auto"), |
|
945 xlim (), |
|
946 ylim (), |
|
947 zlim (), |
6807
|
948 clim (), |
6705
|
949 xlimmode ("auto"), |
|
950 ylimmode ("auto"), |
|
951 zlimmode ("auto"), |
6807
|
952 climmode ("auto"), |
6705
|
953 xlabel (octave_NaN), |
|
954 ylabel (octave_NaN), |
|
955 zlabel (octave_NaN), |
|
956 xgrid ("off"), |
|
957 ygrid ("off"), |
|
958 zgrid ("off"), |
|
959 xminorgrid ("off"), |
|
960 yminorgrid ("off"), |
|
961 zminorgrid ("off"), |
|
962 xtick (Matrix ()), |
|
963 ytick (Matrix ()), |
|
964 ztick (Matrix ()), |
|
965 xtickmode ("auto"), |
|
966 ytickmode ("auto"), |
|
967 ztickmode ("auto"), |
|
968 xticklabel (""), |
|
969 yticklabel (""), |
|
970 zticklabel (""), |
|
971 xticklabelmode ("auto"), |
|
972 yticklabelmode ("auto"), |
|
973 zticklabelmode ("auto"), |
|
974 xscale ("linear"), |
|
975 yscale ("linear"), |
|
976 zscale ("linear"), |
|
977 xdir ("normal"), |
|
978 ydir ("normal"), |
|
979 zdir ("normal"), |
|
980 view (), |
6765
|
981 visible ("on"), |
6705
|
982 nextplot ("replace"), |
|
983 outerposition () |
|
984 { |
|
985 Matrix tlim (1, 2, 0.0); |
|
986 tlim(1) = 1; |
|
987 xlim = tlim; |
|
988 ylim = tlim; |
|
989 zlim = tlim; |
6807
|
990 Matrix cl (1, 2, 0); |
|
991 cl(1) = 1; |
|
992 clim = cl; |
6705
|
993 |
|
994 Matrix tview (1, 2, 0.0); |
|
995 tview(1) = 90; |
|
996 view = tview; |
|
997 |
|
998 Matrix touterposition (1, 4, 0.0); |
|
999 touterposition(2) = 1; |
|
1000 touterposition(3) = 1; |
|
1001 outerposition = touterposition; |
|
1002 } |
|
1003 |
|
1004 void |
|
1005 axes::axes_properties::set (const property_name& name, const octave_value& val) |
6406
|
1006 { |
6705
|
1007 bool modified = true; |
|
1008 |
|
1009 if (name.compare ("parent")) |
|
1010 set_parent (val); |
|
1011 else if (name.compare ("children")) |
|
1012 children = maybe_set_children (children, val); |
|
1013 else if (name.compare ("__modified__")) |
|
1014 { |
|
1015 __modified__ = val.bool_value (); |
|
1016 modified = false; |
|
1017 } |
|
1018 else if (name.compare ("position")) |
|
1019 position = val; |
|
1020 else if (name.compare ("title")) |
|
1021 { |
|
1022 graphics_handle h = ::reparent (val, "set", "title", |
|
1023 __myhandle__, false); |
|
1024 if (! error_state) |
|
1025 { |
|
1026 if (! xisnan (title)) |
|
1027 gh_manager::free (title); |
|
1028 |
|
1029 title = h; |
|
1030 } |
|
1031 } |
|
1032 else if (name.compare ("box")) |
|
1033 box = val; |
|
1034 else if (name.compare ("key")) |
|
1035 key = val; |
|
1036 else if (name.compare ("keybox")) |
|
1037 keybox = val; |
|
1038 else if (name.compare ("keypos")) |
|
1039 keypos = val; |
|
1040 else if (name.compare ("dataaspectratio")) |
|
1041 { |
|
1042 dataaspectratio = val; |
|
1043 dataaspectratiomode = "manual"; |
|
1044 } |
|
1045 else if (name.compare ("dataaspectratiomode")) |
|
1046 dataaspectratiomode = val; |
|
1047 else if (name.compare ("xlim")) |
|
1048 { |
|
1049 xlim = val; |
|
1050 xlimmode = "manual"; |
|
1051 } |
|
1052 else if (name.compare ("ylim")) |
|
1053 { |
|
1054 ylim = val; |
|
1055 ylimmode = "manual"; |
|
1056 } |
|
1057 else if (name.compare ("zlim")) |
|
1058 { |
|
1059 zlim = val; |
|
1060 zlimmode = "manual"; |
|
1061 } |
6807
|
1062 else if (name.compare ("clim")) |
|
1063 { |
|
1064 clim = val; |
|
1065 climmode = "manual"; |
|
1066 } |
6705
|
1067 else if (name.compare ("xlimmode")) |
|
1068 xlimmode = val; |
|
1069 else if (name.compare ("ylimmode")) |
|
1070 ylimmode = val; |
|
1071 else if (name.compare ("zlimmode")) |
|
1072 zlimmode = val; |
6807
|
1073 else if (name.compare ("climmode")) |
|
1074 climmode = val; |
6705
|
1075 else if (name.compare ("xlabel")) |
|
1076 { |
|
1077 graphics_handle h = ::reparent (val, "set", "xlabel", |
|
1078 __myhandle__, false); |
|
1079 if (! error_state) |
|
1080 { |
|
1081 if (! xisnan (xlabel)) |
|
1082 gh_manager::free (xlabel); |
|
1083 |
|
1084 xlabel = h; |
|
1085 } |
|
1086 } |
|
1087 else if (name.compare ("ylabel")) |
|
1088 { |
|
1089 graphics_handle h = ::reparent (val, "set", "ylabel", |
|
1090 __myhandle__, false); |
|
1091 if (! error_state) |
|
1092 { |
|
1093 if (! xisnan (ylabel)) |
|
1094 gh_manager::free (ylabel); |
|
1095 |
|
1096 ylabel = h; |
|
1097 } |
|
1098 } |
|
1099 else if (name.compare ("zlabel")) |
|
1100 { |
|
1101 graphics_handle h = ::reparent (val, "set", "zlabel", |
|
1102 __myhandle__, false); |
|
1103 if (! error_state) |
|
1104 { |
|
1105 if (! xisnan (zlabel)) |
|
1106 gh_manager::free (zlabel); |
|
1107 |
|
1108 zlabel = h; |
|
1109 } |
|
1110 } |
|
1111 else if (name.compare ("xgrid")) |
|
1112 xgrid = val; |
|
1113 else if (name.compare ("ygrid")) |
|
1114 ygrid = val; |
|
1115 else if (name.compare ("zgrid")) |
|
1116 zgrid = val; |
|
1117 else if (name.compare ("xminorgrid")) |
|
1118 xminorgrid = val; |
|
1119 else if (name.compare ("yminorgrid")) |
|
1120 yminorgrid = val; |
|
1121 else if (name.compare ("zminorgrid")) |
|
1122 zminorgrid = val; |
|
1123 else if (name.compare ("xtick")) |
|
1124 { |
|
1125 xtick = val; |
|
1126 xtickmode = "manual"; |
|
1127 } |
|
1128 else if (name.compare ("ytick")) |
6406
|
1129 { |
6705
|
1130 ytick = val; |
|
1131 ytickmode = "manual"; |
|
1132 } |
|
1133 else if (name.compare ("ztick")) |
|
1134 { |
|
1135 ztick = val; |
|
1136 ztickmode = "manual"; |
|
1137 } |
|
1138 else if (name.compare ("xtickmode")) |
|
1139 xtickmode = val; |
|
1140 else if (name.compare ("ytickmode")) |
|
1141 ytickmode = val; |
|
1142 else if (name.compare ("ztickmode")) |
|
1143 ztickmode = val; |
|
1144 else if (name.compare ("xticklabel")) |
|
1145 { |
|
1146 xticklabel = val; |
|
1147 xticklabelmode = "manual"; |
|
1148 } |
|
1149 else if (name.compare ("yticklabel")) |
|
1150 { |
|
1151 yticklabel = val; |
|
1152 yticklabelmode = "manual"; |
|
1153 } |
|
1154 else if (name.compare ("zticklabel")) |
|
1155 { |
|
1156 zticklabel = val; |
|
1157 zticklabelmode = "manual"; |
|
1158 } |
|
1159 else if (name.compare ("xticklabelmode")) |
|
1160 xticklabelmode = val; |
|
1161 else if (name.compare ("yticklabelmode")) |
|
1162 yticklabelmode = val; |
|
1163 else if (name.compare ("zticklabelmode")) |
|
1164 zticklabelmode = val; |
|
1165 else if (name.compare ("xscale")) |
|
1166 xscale = val; |
|
1167 else if (name.compare ("yscale")) |
|
1168 yscale = val; |
|
1169 else if (name.compare ("zscale")) |
|
1170 zscale = val; |
|
1171 else if (name.compare ("xdir")) |
|
1172 xdir = val; |
|
1173 else if (name.compare ("ydir")) |
|
1174 ydir = val; |
|
1175 else if (name.compare ("zdir")) |
|
1176 zdir = val; |
|
1177 else if (name.compare ("view")) |
|
1178 view = val; |
6765
|
1179 else if (name.compare ("visible")) |
|
1180 visible = val; |
6705
|
1181 else if (name.compare ("nextplot")) |
|
1182 nextplot = val; |
|
1183 else if (name.compare ("outerposition")) |
|
1184 outerposition = val; |
|
1185 else |
|
1186 { |
|
1187 modified = false; |
|
1188 warning ("set: invalid property `%s'", name.c_str ()); |
|
1189 } |
6406
|
1190 |
6705
|
1191 if (modified) |
|
1192 mark_modified (); |
|
1193 } |
|
1194 |
|
1195 void |
|
1196 axes::axes_properties::set_defaults (base_graphics_object& obj, |
|
1197 const std::string& mode) |
|
1198 { |
|
1199 position = Matrix (); |
|
1200 title = octave_NaN; |
|
1201 box = "on"; |
|
1202 key = "off"; |
|
1203 keybox = "off"; |
|
1204 keypos = 1; |
|
1205 dataaspectratio = Matrix (1, 3, 1.0); |
|
1206 dataaspectratiomode = "auto"; |
|
1207 |
|
1208 Matrix tlim (1, 2, 0.0); |
|
1209 tlim(1) = 1; |
|
1210 xlim = tlim; |
|
1211 ylim = tlim; |
|
1212 zlim = tlim; |
6807
|
1213 |
|
1214 Matrix cl (1, 2, 0); |
|
1215 cl(1) = 1; |
|
1216 clim = cl; |
|
1217 |
6705
|
1218 xlimmode = "auto"; |
|
1219 ylimmode = "auto"; |
|
1220 zlimmode = "auto"; |
6807
|
1221 climmode = "auto"; |
6705
|
1222 xlabel = octave_NaN; |
|
1223 ylabel = octave_NaN; |
|
1224 zlabel = octave_NaN; |
|
1225 xgrid = "off"; |
|
1226 ygrid = "off"; |
|
1227 zgrid = "off"; |
|
1228 xminorgrid = "off"; |
|
1229 yminorgrid = "off"; |
|
1230 zminorgrid = "off"; |
|
1231 xtick = Matrix (); |
|
1232 ytick = Matrix (); |
|
1233 ztick = Matrix (); |
|
1234 xtickmode = "auto"; |
|
1235 ytickmode = "auto"; |
|
1236 ztickmode = "auto"; |
|
1237 xticklabel = ""; |
|
1238 yticklabel = ""; |
|
1239 zticklabel = ""; |
|
1240 xticklabelmode = "auto"; |
|
1241 yticklabelmode = "auto"; |
|
1242 zticklabelmode = "auto"; |
|
1243 xscale = "linear"; |
|
1244 yscale = "linear"; |
|
1245 zscale = "linear"; |
|
1246 xdir = "normal"; |
|
1247 ydir = "normal"; |
|
1248 zdir = "normal"; |
|
1249 |
|
1250 Matrix tview (1, 2, 0.0); |
|
1251 tview(1) = 90; |
|
1252 view = tview; |
|
1253 |
6765
|
1254 visible = "on"; |
6705
|
1255 nextplot = "replace"; |
|
1256 |
|
1257 // FIXME -- this is not quite right; we should preserve |
|
1258 // "position" and "units". |
|
1259 |
|
1260 if (mode != "replace") |
|
1261 { |
6406
|
1262 Matrix touterposition (1, 4, 0.0); |
|
1263 touterposition(2) = 1; |
|
1264 touterposition(3) = 1; |
|
1265 outerposition = touterposition; |
|
1266 } |
|
1267 |
6705
|
1268 delete_children (); |
6406
|
1269 |
6705
|
1270 children = Matrix (); |
6432
|
1271 |
6705
|
1272 override_defaults (obj); |
|
1273 } |
|
1274 |
|
1275 octave_value |
|
1276 axes::axes_properties::get (void) const |
|
1277 { |
|
1278 Octave_map m; |
6406
|
1279 |
6705
|
1280 if (xisnan (title)) |
|
1281 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1282 |
|
1283 if (xisnan (xlabel)) |
|
1284 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1285 |
6705
|
1286 if (xisnan (ylabel)) |
|
1287 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1288 |
6705
|
1289 if (xisnan (zlabel)) |
|
1290 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1291 |
6705
|
1292 m.assign ("type", type); |
|
1293 m.assign ("parent", parent); |
|
1294 m.assign ("children", children); |
|
1295 m.assign ("__modified__", __modified__); |
|
1296 m.assign ("position", position); |
|
1297 m.assign ("title", title); |
|
1298 m.assign ("box", box); |
|
1299 m.assign ("key", key); |
|
1300 m.assign ("keybox", keybox); |
|
1301 m.assign ("keypos", keypos); |
|
1302 m.assign ("dataaspectratio", dataaspectratio); |
|
1303 m.assign ("dataaspectratiomode", dataaspectratiomode); |
|
1304 m.assign ("xlim", xlim); |
|
1305 m.assign ("ylim", ylim); |
|
1306 m.assign ("zlim", zlim); |
6807
|
1307 m.assign ("clim", clim); |
6705
|
1308 m.assign ("xlimmode", xlimmode); |
|
1309 m.assign ("ylimmode", ylimmode); |
|
1310 m.assign ("zlimmode", zlimmode); |
6807
|
1311 m.assign ("climmode", climmode); |
6705
|
1312 m.assign ("xlabel", xlabel); |
|
1313 m.assign ("ylabel", ylabel); |
|
1314 m.assign ("zlabel", zlabel); |
|
1315 m.assign ("xgrid", xgrid); |
|
1316 m.assign ("ygrid", ygrid); |
|
1317 m.assign ("zgrid", zgrid); |
|
1318 m.assign ("xminorgrid", xminorgrid); |
|
1319 m.assign ("yminorgrid", yminorgrid); |
|
1320 m.assign ("zminorgrid", zminorgrid); |
|
1321 m.assign ("xtick", xtick); |
|
1322 m.assign ("ytick", ytick); |
|
1323 m.assign ("ztick", ztick); |
|
1324 m.assign ("xtickmode", xtickmode); |
|
1325 m.assign ("ytickmode", ytickmode); |
|
1326 m.assign ("ztickmode", ztickmode); |
|
1327 m.assign ("xticklabel", xticklabel); |
|
1328 m.assign ("yticklabel", yticklabel); |
|
1329 m.assign ("zticklabel", zticklabel); |
|
1330 m.assign ("xticklabelmode", xticklabelmode); |
|
1331 m.assign ("yticklabelmode", yticklabelmode); |
|
1332 m.assign ("zticklabelmode", zticklabelmode); |
|
1333 m.assign ("xscale", xscale); |
|
1334 m.assign ("yscale", yscale); |
|
1335 m.assign ("zscale", zscale); |
|
1336 m.assign ("xdir", xdir); |
|
1337 m.assign ("ydir", ydir); |
|
1338 m.assign ("zdir", zdir); |
|
1339 m.assign ("view", view); |
6765
|
1340 m.assign ("visible", visible); |
6705
|
1341 m.assign ("nextplot", nextplot); |
|
1342 m.assign ("outerposition", outerposition); |
6432
|
1343 |
6705
|
1344 return m; |
|
1345 } |
6406
|
1346 |
6705
|
1347 octave_value |
|
1348 axes::axes_properties::get (const property_name& name) const |
|
1349 { |
|
1350 octave_value retval; |
6406
|
1351 |
6705
|
1352 if (name.compare ("type")) |
|
1353 retval = type; |
|
1354 else if (name.compare ("parent")) |
|
1355 retval = parent; |
|
1356 else if (name.compare ("children")) |
|
1357 retval = children; |
|
1358 else if (name.compare ("__modified__")) |
|
1359 retval = __modified__; |
|
1360 else if (name.compare ("position")) |
|
1361 retval = position; |
|
1362 else if (name.compare ("title")) |
6406
|
1363 { |
|
1364 if (xisnan (title)) |
|
1365 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1366 |
6705
|
1367 retval = title; |
|
1368 } |
|
1369 else if (name.compare ("box")) |
|
1370 retval = box; |
|
1371 else if (name.compare ("key")) |
|
1372 retval = key; |
|
1373 else if (name.compare ("keybox")) |
|
1374 retval = keybox; |
|
1375 else if (name.compare ("keypos")) |
|
1376 retval = keypos; |
|
1377 else if (name.compare ("dataaspectratio")) |
|
1378 retval = dataaspectratio; |
|
1379 else if (name.compare ("dataaspectratiomode")) |
|
1380 retval = dataaspectratiomode; |
|
1381 else if (name.compare ("xlim")) |
|
1382 retval = xlim; |
|
1383 else if (name.compare ("ylim")) |
|
1384 retval = ylim; |
|
1385 else if (name.compare ("zlim")) |
|
1386 retval = zlim; |
6807
|
1387 else if (name.compare ("clim")) |
|
1388 retval = clim; |
6705
|
1389 else if (name.compare ("xlimmode")) |
|
1390 retval = xlimmode; |
|
1391 else if (name.compare ("ylimmode")) |
|
1392 retval = ylimmode; |
|
1393 else if (name.compare ("zlimmode")) |
|
1394 retval = zlimmode; |
6807
|
1395 else if (name.compare ("climmode")) |
|
1396 retval = climmode; |
6705
|
1397 else if (name.compare ("xlabel")) |
|
1398 { |
6406
|
1399 if (xisnan (xlabel)) |
|
1400 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1401 |
6705
|
1402 retval = xlabel; |
|
1403 } |
|
1404 else if (name.compare ("ylabel")) |
|
1405 { |
6406
|
1406 if (xisnan (ylabel)) |
|
1407 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1408 |
6705
|
1409 retval = ylabel; |
|
1410 } |
|
1411 else if (name.compare ("zlabel")) |
|
1412 { |
6406
|
1413 if (xisnan (zlabel)) |
|
1414 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1415 |
6705
|
1416 retval = zlabel; |
6406
|
1417 } |
6705
|
1418 else if (name.compare ("xgrid")) |
|
1419 retval = xgrid; |
|
1420 else if (name.compare ("ygrid")) |
|
1421 retval = ygrid; |
|
1422 else if (name.compare ("zgrid")) |
|
1423 retval = zgrid; |
|
1424 else if (name.compare ("xminorgrid")) |
|
1425 retval = xminorgrid; |
|
1426 else if (name.compare ("yminorgrid")) |
|
1427 retval = yminorgrid; |
|
1428 else if (name.compare ("zminorgrid")) |
|
1429 retval = zminorgrid; |
|
1430 else if (name.compare ("xtick")) |
|
1431 retval = xtick; |
|
1432 else if (name.compare ("ytick")) |
|
1433 retval = ytick; |
|
1434 else if (name.compare ("ztick")) |
|
1435 retval = ztick; |
|
1436 else if (name.compare ("xtickmode")) |
|
1437 retval = xtickmode; |
|
1438 else if (name.compare ("ytickmode")) |
|
1439 retval = ytickmode; |
|
1440 else if (name.compare ("ztickmode")) |
|
1441 retval = ztickmode; |
|
1442 else if (name.compare ("xticklabel")) |
|
1443 retval = xticklabel; |
|
1444 else if (name.compare ("yticklabel")) |
|
1445 retval = yticklabel; |
|
1446 else if (name.compare ("zticklabel")) |
|
1447 retval = zticklabel; |
|
1448 else if (name.compare ("xticklabelmode")) |
|
1449 retval = xticklabelmode; |
|
1450 else if (name.compare ("yticklabelmode")) |
|
1451 retval = yticklabelmode; |
|
1452 else if (name.compare ("zticklabelmode")) |
|
1453 retval = zticklabelmode; |
|
1454 else if (name.compare ("xscale")) |
|
1455 retval = xscale; |
|
1456 else if (name.compare ("yscale")) |
|
1457 retval = yscale; |
|
1458 else if (name.compare ("zscale")) |
|
1459 retval = zscale; |
|
1460 else if (name.compare ("xdir")) |
|
1461 retval = xdir; |
|
1462 else if (name.compare ("ydir")) |
|
1463 retval = ydir; |
|
1464 else if (name.compare ("zdir")) |
|
1465 retval = zdir; |
|
1466 else if (name.compare ("view")) |
|
1467 retval = view; |
6765
|
1468 else if (name.compare ("visible")) |
|
1469 retval = visible; |
6705
|
1470 else if (name.compare ("nextplot")) |
|
1471 retval = nextplot; |
|
1472 else if (name.compare ("outerposition")) |
|
1473 retval = outerposition; |
|
1474 else |
|
1475 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1476 |
6705
|
1477 return retval; |
|
1478 } |
6406
|
1479 |
6705
|
1480 void |
|
1481 axes::axes_properties::remove_child (const graphics_handle& h) |
|
1482 { |
|
1483 if (! xisnan (title) && h == title) |
|
1484 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1485 else if (! xisnan (xlabel) && h == xlabel) |
|
1486 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1487 else if (! xisnan (ylabel) && h == ylabel) |
|
1488 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1489 else if (! xisnan (zlabel) && h == zlabel) |
|
1490 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1491 else |
|
1492 base_properties::remove_child (h); |
|
1493 } |
6406
|
1494 |
6705
|
1495 void |
|
1496 axes::axes_properties::delete_children (void) |
|
1497 { |
|
1498 base_properties::delete_children (); |
|
1499 |
|
1500 if (! xisnan (title)) |
|
1501 gh_manager::free (title); |
6406
|
1502 |
6705
|
1503 if (! xisnan (xlabel)) |
|
1504 gh_manager::free (xlabel); |
6406
|
1505 |
6705
|
1506 if (! xisnan (ylabel)) |
|
1507 gh_manager::free (ylabel); |
6406
|
1508 |
6705
|
1509 if (! xisnan (zlabel)) |
|
1510 gh_manager::free (zlabel); |
|
1511 } |
6406
|
1512 |
6705
|
1513 property_list::pval_map_type axes::axes_properties::factory_defaults (void) |
|
1514 { |
|
1515 property_list::pval_map_type m; |
6406
|
1516 |
6705
|
1517 m["position"] = Matrix (); |
|
1518 m["title"] = octave_NaN; |
|
1519 m["box"] = "on"; |
|
1520 m["key"] = "off"; |
|
1521 m["keybox"] = "off"; |
|
1522 m["keypos"] = 1; |
|
1523 m["dataaspectratio"] = Matrix (1, 3, 1.0); |
|
1524 m["dataaspectratiomode"] = "auto"; |
6406
|
1525 |
6705
|
1526 Matrix tlim (1, 2, 0.0); |
|
1527 tlim(1) = 1; |
6406
|
1528 |
6705
|
1529 m["xlim"] = tlim; |
|
1530 m["ylim"] = tlim; |
|
1531 m["zlim"] = tlim; |
6807
|
1532 |
|
1533 Matrix cl(1, 2, 0); |
|
1534 cl(1) = 1; |
|
1535 |
|
1536 m["clim"] = cl; |
6406
|
1537 |
6705
|
1538 m["xlimmode"] = "auto"; |
|
1539 m["ylimmode"] = "auto"; |
|
1540 m["zlimmode"] = "auto"; |
6807
|
1541 m["climmode"] = "auto"; |
6705
|
1542 m["xlabel"] = octave_NaN; |
|
1543 m["ylabel"] = octave_NaN; |
|
1544 m["zlabel"] = octave_NaN; |
|
1545 m["xgrid"] = "off"; |
|
1546 m["ygrid"] = "off"; |
|
1547 m["zgrid"] = "off"; |
|
1548 m["xminorgrid"] = "off"; |
|
1549 m["yminorgrid"] = "off"; |
|
1550 m["zminorgrid"] = "off"; |
|
1551 m["xtick"] = Matrix (); |
|
1552 m["ytick"] = Matrix (); |
|
1553 m["ztick"] = Matrix (); |
|
1554 m["xtickmode"] = "auto"; |
|
1555 m["ytickmode"] = "auto"; |
|
1556 m["ztickmode"] = "auto"; |
|
1557 m["xticklabel"] = ""; |
|
1558 m["yticklabel"] = ""; |
|
1559 m["zticklabel"] = ""; |
|
1560 m["xticklabelmode"] = "auto"; |
|
1561 m["yticklabelmode"] = "auto"; |
|
1562 m["zticklabelmode"] = "auto"; |
|
1563 m["xscale"] = "linear"; |
|
1564 m["yscale"] = "linear"; |
|
1565 m["zscale"] = "linear"; |
|
1566 m["xdir"] = "normal"; |
|
1567 m["ydir"] = "normal"; |
|
1568 m["zdir"] = "normal"; |
6406
|
1569 |
6705
|
1570 Matrix tview (1, 2, 0.0); |
|
1571 tview(1) = 90; |
6406
|
1572 |
6705
|
1573 m["view"] = tview; |
6406
|
1574 |
6765
|
1575 m["visible"] = "on"; |
6705
|
1576 m["nextplot"] = "replace"; |
6406
|
1577 |
6705
|
1578 Matrix touterposition (1, 4, 0.0); |
|
1579 touterposition(2) = 1; |
|
1580 touterposition(3) = 1; |
6406
|
1581 |
6705
|
1582 m["outerposition"] = touterposition; |
6406
|
1583 |
6705
|
1584 return m; |
|
1585 } |
6406
|
1586 |
|
1587 std::string axes::axes_properties::go_name ("axes"); |
|
1588 |
|
1589 // --------------------------------------------------------------------- |
|
1590 |
|
1591 static Matrix |
|
1592 default_data (void) |
|
1593 { |
|
1594 Matrix retval (1, 2); |
|
1595 |
|
1596 retval(0) = 0; |
|
1597 retval(1) = 1; |
|
1598 |
|
1599 return retval; |
|
1600 } |
|
1601 |
6705
|
1602 line::line_properties::line_properties (const graphics_handle& mh, |
|
1603 const graphics_handle& p) |
|
1604 : base_properties (go_name, mh, p), |
|
1605 xdata (default_data ()), |
|
1606 ydata (default_data ()), |
|
1607 zdata (Matrix ()), |
|
1608 ldata (Matrix ()), |
|
1609 udata (Matrix ()), |
|
1610 xldata (Matrix ()), |
|
1611 xudata (Matrix ()), |
|
1612 color (), |
|
1613 linestyle ("-"), |
|
1614 linewidth (0.5), |
|
1615 marker ("none"), |
|
1616 markeredgecolor ("auto"), |
|
1617 markerfacecolor ("none"), |
|
1618 markersize (1), |
|
1619 keylabel ("") |
|
1620 { } |
|
1621 |
|
1622 void |
|
1623 line::line_properties::set (const property_name& name, const octave_value& val) |
6406
|
1624 { |
6705
|
1625 bool modified = true; |
6432
|
1626 |
6705
|
1627 if (name.compare ("parent")) |
|
1628 set_parent (val); |
|
1629 else if (name.compare ("children")) |
|
1630 children = maybe_set_children (children, val); |
|
1631 else if (name.compare ("__modified__")) |
|
1632 { |
|
1633 __modified__ = val.bool_value (); |
|
1634 modified = false; |
6406
|
1635 } |
6705
|
1636 else if (name.compare ("xdata")) |
|
1637 xdata = val; |
|
1638 else if (name.compare ("ydata")) |
|
1639 ydata = val; |
|
1640 else if (name.compare ("zdata")) |
|
1641 zdata = val; |
|
1642 else if (name.compare ("ldata")) |
|
1643 ldata = val; |
|
1644 else if (name.compare ("udata")) |
|
1645 udata = val; |
|
1646 else if (name.compare ("xldata")) |
|
1647 xldata = val; |
|
1648 else if (name.compare ("xudata")) |
|
1649 xudata = val; |
|
1650 else if (name.compare ("color")) |
6790
|
1651 color = val; |
6705
|
1652 else if (name.compare ("linestyle")) |
|
1653 linestyle = val; |
|
1654 else if (name.compare ("linewidth")) |
|
1655 linewidth = val; |
|
1656 else if (name.compare ("marker")) |
|
1657 marker = val; |
|
1658 else if (name.compare ("markeredgecolor")) |
|
1659 markeredgecolor = val; |
|
1660 else if (name.compare ("markerfacecolor")) |
|
1661 markerfacecolor = val; |
|
1662 else if (name.compare ("markersize")) |
|
1663 markersize = val; |
|
1664 else if (name.compare ("keylabel")) |
|
1665 keylabel = val; |
|
1666 else |
6406
|
1667 { |
6705
|
1668 modified = false; |
|
1669 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1670 } |
|
1671 |
6705
|
1672 if (modified) |
|
1673 mark_modified (); |
|
1674 } |
|
1675 |
|
1676 octave_value |
|
1677 line::line_properties::get (void) const |
|
1678 { |
|
1679 Octave_map m; |
6406
|
1680 |
6705
|
1681 m.assign ("type", type); |
|
1682 m.assign ("parent", parent); |
|
1683 m.assign ("children", children); |
|
1684 m.assign ("__modified__", __modified__); |
|
1685 m.assign ("xdata", xdata); |
|
1686 m.assign ("ydata", ydata); |
|
1687 m.assign ("zdata", zdata); |
|
1688 m.assign ("ldata", ldata); |
|
1689 m.assign ("udata", udata); |
|
1690 m.assign ("xldata", xldata); |
|
1691 m.assign ("xudata", xudata); |
|
1692 m.assign ("color", color); |
|
1693 m.assign ("linestyle", linestyle); |
|
1694 m.assign ("linewidth", linewidth); |
|
1695 m.assign ("marker", marker); |
|
1696 m.assign ("markeredgecolor", markeredgecolor); |
|
1697 m.assign ("markerface", markerfacecolor); |
|
1698 m.assign ("markersize", markersize); |
|
1699 m.assign ("keylabel", keylabel); |
6406
|
1700 |
6705
|
1701 return m; |
|
1702 } |
6406
|
1703 |
6705
|
1704 octave_value |
|
1705 line::line_properties::get (const property_name& name) const |
|
1706 { |
|
1707 octave_value retval; |
6406
|
1708 |
6705
|
1709 if (name.compare ("type")) |
|
1710 retval = type; |
|
1711 else if (name.compare ("parent")) |
|
1712 retval = parent; |
|
1713 else if (name.compare ("children")) |
|
1714 retval = children; |
|
1715 else if (name.compare ("__modified__")) |
|
1716 retval = __modified__; |
|
1717 else if (name.compare ("xdata")) |
|
1718 retval = xdata; |
|
1719 else if (name.compare ("ydata")) |
|
1720 retval = ydata; |
|
1721 else if (name.compare ("zdata")) |
|
1722 retval = zdata; |
|
1723 else if (name.compare ("ldata")) |
|
1724 retval = ldata; |
|
1725 else if (name.compare ("udata")) |
|
1726 retval = udata; |
|
1727 else if (name.compare ("xldata")) |
|
1728 retval = xldata; |
|
1729 else if (name.compare ("xudata")) |
|
1730 retval = xudata; |
|
1731 else if (name.compare ("color")) |
|
1732 retval = color; |
|
1733 else if (name.compare ("linestyle")) |
|
1734 retval = linestyle; |
|
1735 else if (name.compare ("linewidth")) |
|
1736 retval = linewidth; |
|
1737 else if (name.compare ("marker")) |
|
1738 retval = marker; |
|
1739 else if (name.compare ("markeredgecolor")) |
|
1740 retval = markeredgecolor; |
|
1741 else if (name.compare ("markerfacecolor")) |
|
1742 retval = markerfacecolor; |
|
1743 else if (name.compare ("markersize")) |
|
1744 retval = markersize; |
|
1745 else if (name.compare ("keylabel")) |
|
1746 retval = keylabel; |
|
1747 else |
|
1748 warning ("get: invalid property `%s'", name.c_str ()); |
6432
|
1749 |
6705
|
1750 return retval; |
|
1751 } |
6406
|
1752 |
6705
|
1753 property_list::pval_map_type line::line_properties::factory_defaults (void) |
|
1754 { |
|
1755 property_list::pval_map_type m; |
6406
|
1756 |
6705
|
1757 m["xdata"] = default_data (); |
|
1758 m["ydata"] = default_data (); |
|
1759 m["zdata"] = Matrix (); |
|
1760 m["ldata"] = Matrix (); |
|
1761 m["udata"] = Matrix (); |
|
1762 m["xldata"] = Matrix (); |
|
1763 m["xudata"] = Matrix (); |
|
1764 m["color"] = color_property (); |
|
1765 m["linestyle"] = "-"; |
|
1766 m["linewidth"] = 0.5; |
|
1767 m["marker"] = "none"; |
|
1768 m["markeredgecolor"] = "auto"; |
|
1769 m["markerfacecolor"] = "none"; |
|
1770 m["markersize"] = 1; |
|
1771 m["keylabel"] = ""; |
6406
|
1772 |
6705
|
1773 return m; |
|
1774 } |
6406
|
1775 |
|
1776 std::string line::line_properties::go_name ("line"); |
|
1777 |
|
1778 // --------------------------------------------------------------------- |
|
1779 |
6705
|
1780 text::text_properties::text_properties (const graphics_handle& mh, |
|
1781 const graphics_handle& p) |
|
1782 : base_properties (go_name, mh, p), |
|
1783 string (""), |
|
1784 units ("data"), |
|
1785 position (Matrix (1, 3, 0.0)), |
6724
|
1786 rotation (0), |
6705
|
1787 horizontalalignment ("left") |
|
1788 { } |
|
1789 |
|
1790 void |
|
1791 text::text_properties::set (const property_name& name, const octave_value& val) |
6406
|
1792 { |
6705
|
1793 bool modified = true; |
6432
|
1794 |
6705
|
1795 if (name.compare ("parent")) |
|
1796 set_parent (val); |
|
1797 else if (name.compare ("children")) |
|
1798 children = maybe_set_children (children, val); |
|
1799 else if (name.compare ("__modified__")) |
|
1800 { |
|
1801 __modified__ = val.bool_value (); |
|
1802 modified = false; |
6406
|
1803 } |
6705
|
1804 else if (name.compare ("string")) |
|
1805 string = val; |
|
1806 else if (name.compare ("units")) |
|
1807 units = val; |
|
1808 else if (name.compare ("position")) |
|
1809 position = val; |
6724
|
1810 else if (name.compare ("rotation")) |
|
1811 rotation = val; |
6705
|
1812 else if (name.compare ("horizontalalignment")) |
|
1813 horizontalalignment = val; |
|
1814 else |
6406
|
1815 { |
6705
|
1816 modified = false; |
|
1817 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1818 } |
|
1819 |
6705
|
1820 if (modified) |
|
1821 mark_modified (); |
|
1822 } |
6406
|
1823 |
6705
|
1824 octave_value |
|
1825 text::text_properties::get (void) const |
|
1826 { |
|
1827 Octave_map m; |
6406
|
1828 |
6705
|
1829 m.assign ("type", type); |
|
1830 m.assign ("parent", parent); |
|
1831 m.assign ("children", children); |
|
1832 m.assign ("__modified__", __modified__); |
|
1833 m.assign ("string", string); |
|
1834 m.assign ("units", units); |
|
1835 m.assign ("position", position); |
6724
|
1836 m.assign ("rotation", rotation); |
6705
|
1837 m.assign ("horizontalalignment", horizontalalignment); |
6406
|
1838 |
6705
|
1839 return m; |
|
1840 } |
6406
|
1841 |
6705
|
1842 octave_value |
|
1843 text::text_properties::get (const property_name& name) const |
|
1844 { |
|
1845 octave_value retval; |
6406
|
1846 |
6705
|
1847 if (name.compare ("type")) |
|
1848 retval = type; |
|
1849 else if (name.compare ("parent")) |
|
1850 retval = parent; |
|
1851 else if (name.compare ("children")) |
|
1852 retval = children; |
|
1853 else if (name.compare ("__modified__")) |
|
1854 retval = __modified__; |
|
1855 else if (name.compare ("string")) |
|
1856 retval = string; |
|
1857 else if (name.compare ("units")) |
|
1858 retval = units; |
|
1859 else if (name.compare ("position")) |
|
1860 retval = position; |
6724
|
1861 else if (name.compare ("rotation")) |
|
1862 retval = rotation; |
6705
|
1863 else if (name.compare ("horizontalalignment")) |
|
1864 retval = horizontalalignment; |
|
1865 else |
|
1866 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1867 |
6705
|
1868 return retval; |
|
1869 } |
6406
|
1870 |
6705
|
1871 property_list::pval_map_type |
|
1872 text::text_properties::factory_defaults (void) |
|
1873 { |
|
1874 property_list::pval_map_type m; |
6406
|
1875 |
6705
|
1876 m["string"] = ""; |
|
1877 m["units"] = "data"; |
|
1878 m["position"] = Matrix (1, 3, 0.0); |
6724
|
1879 m["rotation"] = 0; |
6705
|
1880 m["horizontalalignment"] = "left"; |
6406
|
1881 |
6705
|
1882 return m; |
|
1883 } |
6406
|
1884 |
|
1885 std::string text::text_properties::go_name ("text"); |
|
1886 |
|
1887 // --------------------------------------------------------------------- |
|
1888 |
6705
|
1889 image::image_properties::image_properties (const graphics_handle& mh, |
|
1890 const graphics_handle& p) |
|
1891 : base_properties (go_name, mh, p), |
|
1892 cdata (Matrix ()), |
|
1893 xdata (Matrix ()), |
|
1894 ydata (Matrix ()) |
|
1895 { } |
|
1896 |
|
1897 void |
|
1898 image::image_properties::set (const property_name& name, |
|
1899 const octave_value& val) |
6406
|
1900 { |
6705
|
1901 bool modified = true; |
6432
|
1902 |
6705
|
1903 if (name.compare ("parent")) |
|
1904 set_parent (val); |
|
1905 else if (name.compare ("children")) |
|
1906 children = maybe_set_children (children, val); |
|
1907 else if (name.compare ("__modified__")) |
|
1908 { |
|
1909 __modified__ = val.bool_value (); |
|
1910 modified = false; |
6406
|
1911 } |
6705
|
1912 else if (name.compare ("cdata")) |
|
1913 cdata = val; |
|
1914 else if (name.compare ("xdata")) |
|
1915 xdata = val; |
|
1916 else if (name.compare ("ydata")) |
|
1917 ydata = val; |
|
1918 else |
6406
|
1919 { |
6705
|
1920 modified = false; |
|
1921 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1922 } |
|
1923 |
6705
|
1924 if (modified) |
|
1925 mark_modified (); |
|
1926 } |
6406
|
1927 |
6705
|
1928 octave_value |
|
1929 image::image_properties::get (void) const |
|
1930 { |
|
1931 Octave_map m; |
6406
|
1932 |
6705
|
1933 m.assign ("type", type); |
|
1934 m.assign ("parent", parent); |
|
1935 m.assign ("children", children); |
|
1936 m.assign ("__modified__", __modified__); |
|
1937 m.assign ("cdata", cdata); |
|
1938 m.assign ("xdata", xdata); |
|
1939 m.assign ("ydata", ydata); |
6406
|
1940 |
6705
|
1941 return m; |
|
1942 } |
6406
|
1943 |
6705
|
1944 octave_value |
|
1945 image::image_properties::get (const property_name& name) const |
|
1946 { |
|
1947 octave_value retval; |
6406
|
1948 |
6705
|
1949 if (name.compare ("type")) |
|
1950 retval = type; |
|
1951 else if (name.compare ("parent")) |
|
1952 retval = parent; |
|
1953 else if (name.compare ("children")) |
|
1954 retval = children; |
|
1955 else if (name.compare ("__modified__")) |
|
1956 retval = __modified__; |
|
1957 else if (name.compare ("cdata")) |
|
1958 retval = cdata; |
|
1959 else if (name.compare ("xdata")) |
|
1960 retval = xdata; |
|
1961 else if (name.compare ("ydata")) |
|
1962 retval = ydata; |
|
1963 else |
|
1964 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1965 |
6705
|
1966 return retval; |
|
1967 } |
6406
|
1968 |
6705
|
1969 property_list::pval_map_type image::image_properties::factory_defaults (void) |
|
1970 { |
|
1971 property_list::pval_map_type m; |
6406
|
1972 |
6705
|
1973 m["cdata"] = Matrix (); |
|
1974 m["xdata"] = Matrix (); |
|
1975 m["ydata"] = Matrix (); |
6406
|
1976 |
6705
|
1977 return m; |
|
1978 } |
6406
|
1979 |
|
1980 std::string image::image_properties::go_name ("image"); |
|
1981 |
|
1982 // --------------------------------------------------------------------- |
|
1983 |
6807
|
1984 patch::patch_properties::patch_properties (const graphics_handle& mh, |
|
1985 const graphics_handle& p) |
|
1986 : base_properties (go_name, mh, p), |
|
1987 cdata (Matrix ()), |
|
1988 xdata (Matrix ()), |
|
1989 ydata (Matrix ()), |
|
1990 zdata (Matrix ()), |
|
1991 facecolor (radio_values("{flat}|none|interp")), |
|
1992 facealpha (1.0), |
|
1993 edgecolor (color_values(0, 0, 0), radio_values("flat|none|interp")), |
|
1994 linestyle ("-"), |
|
1995 linewidth (0.5), |
|
1996 marker ("none"), |
|
1997 markeredgecolor ("auto"), |
|
1998 markerfacecolor ("none"), |
|
1999 markersize (1) |
|
2000 { } |
|
2001 |
|
2002 void |
|
2003 patch::patch_properties::set (const property_name& name, |
|
2004 const octave_value& val) |
|
2005 { |
|
2006 bool modified = true; |
|
2007 |
|
2008 if (name.compare ("parent")) |
|
2009 set_parent (val); |
|
2010 else if (name.compare ("children")) |
|
2011 children = maybe_set_children (children, val); |
|
2012 else if (name.compare ("__modified__")) |
|
2013 { |
|
2014 __modified__ = val.bool_value (); |
|
2015 modified = false; |
|
2016 } |
|
2017 else if (name.compare ("cdata")) |
|
2018 cdata = val; |
|
2019 else if (name.compare ("xdata")) |
|
2020 xdata = val; |
|
2021 else if (name.compare ("ydata")) |
|
2022 ydata = val; |
|
2023 else if (name.compare ("zdata")) |
|
2024 zdata = val; |
|
2025 else if (name.compare ("facecolor")) |
|
2026 facecolor = val; |
|
2027 else if (name.compare ("facealpha")) |
|
2028 facealpha = val; |
|
2029 else if (name.compare ("edgecolor")) |
|
2030 edgecolor = val; |
|
2031 else if (name.compare ("linestyle")) |
|
2032 linestyle = val; |
|
2033 else if (name.compare ("linewidth")) |
|
2034 linewidth = val; |
|
2035 else if (name.compare ("marker")) |
|
2036 marker = val; |
|
2037 else if (name.compare ("markeredgecolor")) |
|
2038 markeredgecolor = val; |
|
2039 else if (name.compare ("markerfacecolor")) |
|
2040 markerfacecolor = val; |
|
2041 else if (name.compare ("markersize")) |
|
2042 markersize = val; |
|
2043 |
|
2044 else |
|
2045 { |
|
2046 modified = false; |
|
2047 warning ("set: invalid property `%s'", name.c_str ()); |
|
2048 } |
|
2049 |
|
2050 if (modified) |
|
2051 mark_modified (); |
|
2052 } |
|
2053 |
|
2054 octave_value |
|
2055 patch::patch_properties::get (void) const |
|
2056 { |
|
2057 Octave_map m; |
|
2058 |
|
2059 m.assign ("type", type); |
|
2060 m.assign ("parent", parent); |
|
2061 m.assign ("children", children); |
|
2062 m.assign ("__modified__", __modified__); |
|
2063 m.assign ("cdata", cdata); |
|
2064 m.assign ("xdata", xdata); |
|
2065 m.assign ("ydata", ydata); |
|
2066 m.assign ("zdata", zdata); |
|
2067 m.assign ("facecolor", facecolor); |
|
2068 m.assign ("facealpha", facealpha); |
|
2069 m.assign ("edgecolor", edgecolor); |
|
2070 m.assign ("linestyle", linestyle); |
|
2071 m.assign ("linewidth", linewidth); |
|
2072 m.assign ("marker", marker); |
|
2073 m.assign ("markeredgecolor", markeredgecolor); |
|
2074 m.assign ("markerface", markerfacecolor); |
|
2075 m.assign ("markersize", markersize); |
|
2076 |
|
2077 return m; |
|
2078 } |
|
2079 |
|
2080 octave_value |
|
2081 patch::patch_properties::get (const property_name& name) const |
|
2082 { |
|
2083 octave_value retval; |
|
2084 |
|
2085 if (name.compare ("type")) |
|
2086 retval = type; |
|
2087 else if (name.compare ("parent")) |
|
2088 retval = parent; |
|
2089 else if (name.compare ("children")) |
|
2090 retval = children; |
|
2091 else if (name.compare ("__modified__")) |
|
2092 retval = __modified__; |
|
2093 else if (name.compare ("cdata")) |
|
2094 retval = cdata; |
|
2095 else if (name.compare ("xdata")) |
|
2096 retval = xdata; |
|
2097 else if (name.compare ("ydata")) |
|
2098 retval = ydata; |
|
2099 else if (name.compare ("zdata")) |
|
2100 retval = zdata; |
|
2101 else if (name.compare ("facecolor")) |
|
2102 retval = facecolor; |
|
2103 else if (name.compare ("facealpha")) |
|
2104 retval = facecolor; |
|
2105 else if (name.compare ("egdecolor")) |
|
2106 retval = edgecolor; |
|
2107 else if (name.compare ("linestyle")) |
|
2108 retval = linestyle; |
|
2109 else if (name.compare ("linewidth")) |
|
2110 retval = linewidth; |
|
2111 else if (name.compare ("marker")) |
|
2112 retval = marker; |
|
2113 else if (name.compare ("markeredgecolor")) |
|
2114 retval = markeredgecolor; |
|
2115 else if (name.compare ("markerfacecolor")) |
|
2116 retval = markerfacecolor; |
|
2117 else if (name.compare ("markersize")) |
|
2118 retval = markersize; |
|
2119 else |
|
2120 warning ("get: invalid property `%s'", name.c_str ()); |
|
2121 |
|
2122 return retval; |
|
2123 } |
|
2124 |
|
2125 property_list::pval_map_type patch::patch_properties::factory_defaults (void) |
|
2126 { |
|
2127 property_list::pval_map_type m; |
|
2128 |
|
2129 m["cdata"] = Matrix (); |
|
2130 m["xdata"] = Matrix (); |
|
2131 m["ydata"] = Matrix (); |
|
2132 m["zdata"] = Matrix (); |
|
2133 m["facecolor"] = color_property(); |
|
2134 m["facealpha"] = 1.0; |
|
2135 m["edgecolor"] = color_property("black"); |
|
2136 m["linestyle"] = "-"; |
|
2137 m["linewidth"] = 0.5; |
|
2138 m["marker"] = "none"; |
|
2139 m["markeredgecolor"] = "auto"; |
|
2140 m["markerfacecolor"] = "none"; |
|
2141 m["markersize"] = 1; |
|
2142 |
|
2143 |
|
2144 return m; |
|
2145 } |
|
2146 |
|
2147 std::string patch::patch_properties::go_name ("patch"); |
|
2148 |
|
2149 // --------------------------------------------------------------------- |
|
2150 |
6705
|
2151 surface::surface_properties::surface_properties (const graphics_handle& mh, |
|
2152 const graphics_handle& p) |
|
2153 : base_properties (go_name, mh, p), |
|
2154 xdata (Matrix ()), |
|
2155 ydata (Matrix ()), |
|
2156 zdata (Matrix ()), |
|
2157 keylabel ("") |
|
2158 { } |
|
2159 |
|
2160 void |
|
2161 surface::surface_properties::set (const property_name& name, |
|
2162 const octave_value& val) |
6406
|
2163 { |
6705
|
2164 bool modified = true; |
6432
|
2165 |
6705
|
2166 if (name.compare ("parent")) |
|
2167 set_parent (val); |
|
2168 else if (name.compare ("children")) |
|
2169 children = maybe_set_children (children, val); |
|
2170 else if (name.compare ("__modified__")) |
|
2171 { |
|
2172 __modified__ = val.bool_value (); |
|
2173 modified = false; |
6406
|
2174 } |
6705
|
2175 else if (name.compare ("xdata")) |
|
2176 xdata = val; |
|
2177 else if (name.compare ("ydata")) |
|
2178 ydata = val; |
|
2179 else if (name.compare ("zdata")) |
|
2180 zdata = val; |
|
2181 else if (name.compare ("keylabel")) |
|
2182 keylabel = val; |
|
2183 else |
6406
|
2184 { |
6705
|
2185 modified = false; |
|
2186 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2187 } |
|
2188 |
6705
|
2189 if (modified) |
|
2190 mark_modified (); |
|
2191 } |
6406
|
2192 |
6705
|
2193 octave_value |
|
2194 surface::surface_properties::get (void) const |
|
2195 { |
|
2196 Octave_map m; |
6406
|
2197 |
6705
|
2198 m.assign ("type", type); |
|
2199 m.assign ("parent", parent); |
|
2200 m.assign ("children", children); |
|
2201 m.assign ("__modified__", __modified__); |
|
2202 m.assign ("xdata", xdata); |
|
2203 m.assign ("ydata", ydata); |
|
2204 m.assign ("zdata", zdata); |
|
2205 m.assign ("keylabel", keylabel); |
6406
|
2206 |
6705
|
2207 return m; |
|
2208 } |
6406
|
2209 |
6705
|
2210 octave_value |
|
2211 surface::surface_properties::get (const property_name& name) const |
|
2212 { |
|
2213 octave_value retval; |
6406
|
2214 |
6705
|
2215 if (name.compare ("type")) |
|
2216 retval = type; |
|
2217 else if (name.compare ("parent")) |
|
2218 retval = parent; |
|
2219 else if (name.compare ("children")) |
|
2220 retval = children; |
|
2221 else if (name.compare ("__modified__")) |
|
2222 retval = __modified__; |
|
2223 else if (name.compare ("xdata")) |
|
2224 retval = xdata; |
|
2225 else if (name.compare ("ydata")) |
|
2226 retval = ydata; |
|
2227 else if (name.compare ("zdata")) |
|
2228 retval = zdata; |
|
2229 else if (name.compare ("keylabel")) |
|
2230 retval = keylabel; |
|
2231 else |
|
2232 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2233 |
6705
|
2234 return retval; |
|
2235 } |
6406
|
2236 |
6705
|
2237 property_list::pval_map_type |
|
2238 surface::surface_properties::factory_defaults (void) |
|
2239 { |
|
2240 property_list::pval_map_type m; |
6406
|
2241 |
6705
|
2242 m["xdata"] = Matrix (); |
|
2243 m["ydata"] = Matrix (); |
|
2244 m["zdata"] = Matrix (); |
|
2245 m["keylabel"] = ""; |
6406
|
2246 |
6705
|
2247 return m; |
|
2248 } |
6406
|
2249 |
|
2250 std::string surface::surface_properties::go_name ("surface"); |
|
2251 |
|
2252 // --------------------------------------------------------------------- |
|
2253 |
|
2254 octave_value |
|
2255 base_graphics_object::get_default (const property_name& name) const |
|
2256 { |
|
2257 graphics_handle parent = get_parent (); |
|
2258 graphics_object parent_obj = gh_manager::get_object (parent); |
|
2259 |
|
2260 return parent_obj.get_default (type () + name); |
|
2261 } |
|
2262 |
|
2263 octave_value |
|
2264 base_graphics_object::get_factory_default (const property_name& name) const |
|
2265 { |
|
2266 graphics_object parent_obj = gh_manager::get_object (0); |
|
2267 |
|
2268 return parent_obj.get_factory_default (type () + name); |
|
2269 } |
|
2270 |
|
2271 gh_manager::gh_manager (void) |
|
2272 : handle_map (), handle_free_list (), next_handle (-1) |
|
2273 { |
|
2274 handle_map[0] = graphics_object (new root_figure ()); |
|
2275 } |
|
2276 |
|
2277 graphics_handle |
|
2278 gh_manager::do_make_graphics_handle (const std::string& go_name, |
|
2279 const graphics_handle& p) |
|
2280 { |
|
2281 graphics_handle h = get_handle (go_name); |
|
2282 |
|
2283 base_graphics_object *go = 0; |
|
2284 |
|
2285 if (go_name == "figure") |
|
2286 go = new figure (h, p); |
|
2287 else if (go_name == "axes") |
|
2288 go = new axes (h, p); |
|
2289 else if (go_name == "line") |
|
2290 go = new line (h, p); |
|
2291 else if (go_name == "text") |
|
2292 go = new text (h, p); |
|
2293 else if (go_name == "image") |
|
2294 go = new image (h, p); |
6807
|
2295 else if (go_name == "patch") |
|
2296 go = new patch (h, p); |
6406
|
2297 else if (go_name == "surface") |
|
2298 go = new surface (h, p); |
|
2299 if (go) |
|
2300 handle_map[h] = graphics_object (go); |
|
2301 else |
|
2302 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", |
|
2303 go_name.c_str ()); |
|
2304 |
|
2305 return h; |
|
2306 } |
|
2307 |
|
2308 graphics_handle |
|
2309 gh_manager::do_make_figure_handle (double val) |
|
2310 { |
|
2311 graphics_handle h = val; |
|
2312 |
|
2313 handle_map[h] = graphics_object (new figure (h, 0)); |
|
2314 |
|
2315 return h; |
|
2316 } |
|
2317 |
|
2318 void |
|
2319 gh_manager::do_push_figure (const graphics_handle& h) |
|
2320 { |
|
2321 do_pop_figure (h); |
|
2322 |
|
2323 figure_list.push_front (h); |
|
2324 } |
|
2325 |
|
2326 void |
|
2327 gh_manager::do_pop_figure (const graphics_handle& h) |
|
2328 { |
|
2329 for (figure_list_iterator p = figure_list.begin (); |
|
2330 p != figure_list.end (); |
|
2331 p++) |
|
2332 { |
|
2333 if (*p == h) |
|
2334 { |
|
2335 figure_list.erase (p); |
|
2336 break; |
|
2337 } |
|
2338 } |
|
2339 } |
|
2340 |
|
2341 property_list::plist_map_type |
|
2342 root_figure::init_factory_properties (void) |
|
2343 { |
|
2344 property_list::plist_map_type plist_map; |
|
2345 |
|
2346 plist_map["figure"] = figure::figure_properties::factory_defaults (); |
|
2347 plist_map["axes"] = axes::axes_properties::factory_defaults (); |
|
2348 plist_map["line"] = line::line_properties::factory_defaults (); |
|
2349 plist_map["text"] = text::text_properties::factory_defaults (); |
|
2350 plist_map["image"] = image::image_properties::factory_defaults (); |
6807
|
2351 plist_map["patch"] = patch::patch_properties::factory_defaults (); |
6406
|
2352 plist_map["surface"] = surface::surface_properties::factory_defaults (); |
|
2353 |
|
2354 return plist_map; |
|
2355 } |
|
2356 |
|
2357 // --------------------------------------------------------------------- |
|
2358 |
|
2359 DEFUN (ishandle, args, , |
|
2360 "-*- texinfo -*-\n\ |
6678
|
2361 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406
|
2362 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
|
2363 @end deftypefn") |
|
2364 { |
|
2365 octave_value retval; |
|
2366 |
|
2367 if (args.length () == 1) |
|
2368 retval = is_handle (args(0)); |
|
2369 else |
|
2370 print_usage (); |
|
2371 |
|
2372 return retval; |
|
2373 } |
|
2374 |
|
2375 DEFUN (set, args, , |
|
2376 "-*- texinfo -*-\n\ |
6678
|
2377 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ |
6732
|
2378 Set the named property value or vector @var{p} to the value @var{v}\n\ |
|
2379 in the graphics handle @var{h}.\n\ |
6406
|
2380 @end deftypefn") |
|
2381 { |
|
2382 octave_value retval; |
|
2383 |
|
2384 int nargin = args.length (); |
|
2385 |
|
2386 if (nargin > 0) |
|
2387 { |
6732
|
2388 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2389 |
|
2390 if (! error_state) |
6732
|
2391 { |
6733
|
2392 bool request_drawnow = false; |
|
2393 |
6732
|
2394 for (octave_idx_type n = 0; n < hcv.length (); n++) |
|
2395 { |
|
2396 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2397 |
6732
|
2398 if (obj) |
|
2399 { |
|
2400 obj.set (args.splice (0, 1)); |
6406
|
2401 |
6733
|
2402 request_drawnow = true; |
6732
|
2403 } |
|
2404 else |
6733
|
2405 { |
|
2406 error ("set: invalid handle (= %g)", hcv(n)); |
|
2407 break; |
|
2408 } |
6732
|
2409 } |
6733
|
2410 |
|
2411 if (! error_state && request_drawnow) |
|
2412 feval ("__request_drawnow__"); |
6732
|
2413 } |
6406
|
2414 else |
6732
|
2415 error ("set: expecting graphics handle as first argument"); |
6406
|
2416 } |
|
2417 else |
|
2418 print_usage (); |
|
2419 |
|
2420 return retval; |
|
2421 } |
|
2422 |
|
2423 DEFUN (get, args, , |
|
2424 "-*- texinfo -*-\n\ |
6678
|
2425 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406
|
2426 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
|
2427 If @var{p} is omitted, return the complete property list for @var{h}.\n\ |
6732
|
2428 If @var{h} is a vector, return a cell array including the property\n\ |
|
2429 values or lists respectively.\n\ |
6406
|
2430 @end deftypefn") |
|
2431 { |
|
2432 octave_value retval; |
6732
|
2433 octave_value_list vlist; |
6406
|
2434 |
|
2435 int nargin = args.length (); |
|
2436 |
|
2437 if (nargin == 1 || nargin == 2) |
|
2438 { |
6732
|
2439 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2440 |
|
2441 if (! error_state) |
6732
|
2442 { |
6733
|
2443 octave_idx_type len = hcv.length (); |
|
2444 |
|
2445 vlist.resize (len); |
|
2446 |
|
2447 for (octave_idx_type n = 0; n < len; n++) |
6732
|
2448 { |
|
2449 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2450 |
6732
|
2451 if (obj) |
|
2452 { |
|
2453 if (nargin == 1) |
|
2454 vlist(n) = obj.get (); |
|
2455 else |
|
2456 { |
|
2457 property_name property = args(1).string_value (); |
6406
|
2458 |
6732
|
2459 if (! error_state) |
|
2460 vlist(n) = obj.get (property); |
|
2461 else |
6733
|
2462 { |
|
2463 error ("get: expecting property name as second argument"); |
|
2464 break; |
|
2465 } |
6732
|
2466 } |
|
2467 } |
|
2468 else |
6733
|
2469 { |
|
2470 error ("get: invalid handle (= %g)", hcv(n)); |
|
2471 break; |
|
2472 } |
6732
|
2473 } |
|
2474 } |
6406
|
2475 else |
6732
|
2476 error ("get: expecting graphics handle as first argument"); |
6406
|
2477 } |
|
2478 else |
|
2479 print_usage (); |
|
2480 |
6733
|
2481 if (! error_state) |
6732
|
2482 { |
6733
|
2483 octave_idx_type len = vlist.length (); |
|
2484 |
|
2485 if (len > 1) |
|
2486 retval = Cell (vlist); |
|
2487 else if (len == 1) |
|
2488 retval = vlist(0); |
6732
|
2489 } |
|
2490 |
6406
|
2491 return retval; |
|
2492 } |
|
2493 |
|
2494 static octave_value |
|
2495 make_graphics_object (const std::string& go_name, |
6732
|
2496 const octave_value_list& args) |
6406
|
2497 { |
|
2498 octave_value retval; |
|
2499 |
|
2500 double val = args(0).double_value (); |
|
2501 |
|
2502 if (! error_state) |
|
2503 { |
|
2504 graphics_handle parent = gh_manager::lookup (val); |
|
2505 |
|
2506 if (! xisnan (parent)) |
|
2507 { |
|
2508 graphics_handle h |
|
2509 = gh_manager::make_graphics_handle (go_name, parent); |
|
2510 |
|
2511 if (! error_state) |
|
2512 { |
|
2513 adopt (parent, h); |
|
2514 |
|
2515 xset (h, args.splice (0, 1)); |
|
2516 |
|
2517 retval = h; |
|
2518 } |
|
2519 else |
|
2520 error ("__go%s__: unable to create graphics handle", |
|
2521 go_name.c_str ()); |
|
2522 } |
|
2523 else |
|
2524 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2525 } |
|
2526 else |
|
2527 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2528 |
|
2529 return retval; |
|
2530 } |
|
2531 |
|
2532 DEFUN (__go_figure__, args, , |
|
2533 "-*- texinfo -*-\n\ |
|
2534 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ |
|
2535 Create a figure graphics object.\n\ |
|
2536 @end deftypefn") |
|
2537 { |
|
2538 octave_value retval; |
|
2539 |
|
2540 if (args.length () > 0) |
|
2541 { |
|
2542 double val = args(0).double_value (); |
|
2543 |
|
2544 if (! error_state) |
|
2545 { |
|
2546 if (is_figure (val)) |
|
2547 { |
|
2548 graphics_handle h = gh_manager::lookup (val); |
|
2549 |
|
2550 xset (h, args.splice (0, 1)); |
|
2551 |
|
2552 retval = h; |
|
2553 } |
|
2554 else |
|
2555 { |
|
2556 graphics_handle h = octave_NaN; |
|
2557 |
|
2558 if (xisnan (val)) |
|
2559 h = gh_manager::make_graphics_handle ("figure", 0); |
|
2560 else if (val > 0 && D_NINT (val) == val) |
|
2561 h = gh_manager::make_figure_handle (val); |
|
2562 else |
|
2563 error ("__go_figure__: invalid figure number"); |
|
2564 |
|
2565 if (! (error_state || xisnan (h))) |
|
2566 { |
|
2567 adopt (0, h); |
|
2568 |
|
2569 xset (h, args.splice (0, 1)); |
|
2570 |
|
2571 retval = h; |
|
2572 } |
|
2573 else |
|
2574 error ("__go_figure__: failed to create figure handle"); |
|
2575 } |
|
2576 } |
|
2577 else |
|
2578 error ("__go_figure__: expecting figure number to be double value"); |
|
2579 } |
|
2580 else |
|
2581 print_usage (); |
|
2582 |
|
2583 return retval; |
|
2584 } |
|
2585 |
|
2586 #define GO_BODY(TYPE) \ |
|
2587 octave_value retval; \ |
|
2588 \ |
|
2589 if (args.length () > 0) \ |
|
2590 retval = make_graphics_object (#TYPE, args); \ |
|
2591 else \ |
|
2592 print_usage (); \ |
|
2593 \ |
|
2594 return retval |
|
2595 |
|
2596 DEFUN (__go_axes__, args, , |
|
2597 "-*- texinfo -*-\n\ |
|
2598 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ |
|
2599 Create an axes graphics object.\n\ |
|
2600 @end deftypefn") |
|
2601 { |
|
2602 GO_BODY (axes); |
|
2603 } |
|
2604 |
|
2605 DEFUN (__go_line__, args, , |
|
2606 "-*- texinfo -*-\n\ |
|
2607 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ |
|
2608 Create a line graphics object.\n\ |
|
2609 @end deftypefn") |
|
2610 { |
|
2611 GO_BODY (line); |
|
2612 } |
|
2613 |
|
2614 DEFUN (__go_text__, args, , |
|
2615 "-*- texinfo -*-\n\ |
|
2616 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ |
|
2617 Create a text graphics object.\n\ |
|
2618 @end deftypefn") |
|
2619 { |
|
2620 GO_BODY (text); |
|
2621 } |
|
2622 |
|
2623 DEFUN (__go_image__, args, , |
|
2624 "-*- texinfo -*-\n\ |
|
2625 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ |
|
2626 Create an image graphics object.\n\ |
|
2627 @end deftypefn") |
|
2628 { |
|
2629 GO_BODY (image); |
|
2630 } |
|
2631 |
|
2632 DEFUN (__go_surface__, args, , |
|
2633 "-*- texinfo -*-\n\ |
|
2634 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ |
|
2635 Create a surface graphics object.\n\ |
|
2636 @end deftypefn") |
|
2637 { |
|
2638 GO_BODY (surface); |
|
2639 } |
|
2640 |
6807
|
2641 DEFUN (__go_patch__, args, , |
|
2642 "-*- texinfo -*-\n\ |
|
2643 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ |
|
2644 Create a patch graphics object.\n\ |
|
2645 @end deftypefn") |
|
2646 { |
|
2647 GO_BODY (patch); |
|
2648 } |
|
2649 |
6406
|
2650 DEFUN (__go_delete__, args, , |
|
2651 "-*- texinfo -*-\n\ |
|
2652 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ |
|
2653 @end deftypefn") |
|
2654 { |
|
2655 octave_value_list retval; |
|
2656 |
|
2657 if (args.length () == 1) |
|
2658 { |
|
2659 graphics_handle h = octave_NaN; |
|
2660 |
|
2661 double val = args(0).double_value (); |
|
2662 |
|
2663 if (! error_state) |
|
2664 { |
|
2665 h = gh_manager::lookup (val); |
|
2666 |
|
2667 if (! xisnan (h)) |
|
2668 { |
|
2669 graphics_object obj = gh_manager::get_object (h); |
|
2670 |
|
2671 graphics_handle parent_h = obj.get_parent (); |
|
2672 |
|
2673 graphics_object parent_obj = gh_manager::get_object (parent_h); |
|
2674 |
|
2675 parent_obj.remove_child (h); |
|
2676 |
|
2677 gh_manager::free (h); |
|
2678 } |
|
2679 else |
|
2680 error ("delete: invalid graphics object (= %g)", val); |
|
2681 } |
|
2682 else |
|
2683 error ("delete: invalid graphics object"); |
|
2684 } |
|
2685 else |
|
2686 print_usage (); |
|
2687 |
|
2688 return retval; |
|
2689 } |
|
2690 |
|
2691 DEFUN (__go_axes_init__, args, , |
|
2692 "-*- texinfo -*-\n\ |
|
2693 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ |
|
2694 Initialize axes object.\n\ |
|
2695 @end deftypefn") |
|
2696 { |
|
2697 octave_value retval; |
|
2698 |
|
2699 int nargin = args.length (); |
|
2700 |
|
2701 std::string mode = ""; |
|
2702 |
|
2703 if (nargin == 2) |
|
2704 { |
|
2705 mode = args(1).string_value (); |
|
2706 |
|
2707 if (error_state) |
|
2708 return retval; |
|
2709 } |
|
2710 |
|
2711 if (nargin == 1 || nargin == 2) |
|
2712 { |
|
2713 graphics_handle h = octave_NaN; |
|
2714 |
|
2715 double val = args(0).double_value (); |
|
2716 |
|
2717 if (! error_state) |
|
2718 { |
|
2719 h = gh_manager::lookup (val); |
|
2720 |
|
2721 if (! xisnan (h)) |
|
2722 { |
|
2723 graphics_object obj = gh_manager::get_object (h); |
|
2724 |
|
2725 obj.set_defaults (mode); |
|
2726 } |
|
2727 else |
|
2728 error ("__go_axes_init__: invalid graphics object (= %g)", val); |
|
2729 } |
|
2730 else |
|
2731 error ("__go_axes_init__: invalid graphics object"); |
|
2732 } |
|
2733 else |
|
2734 print_usage (); |
|
2735 |
|
2736 return retval; |
|
2737 } |
|
2738 |
|
2739 DEFUN (__go_handles__, , , |
|
2740 "-*- texinfo -*-\n\ |
|
2741 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ |
|
2742 Return current list of function handles.\n\ |
|
2743 @end deftypefn") |
|
2744 { |
6425
|
2745 return octave_value (gh_manager::handle_list ()); |
|
2746 } |
|
2747 |
|
2748 DEFUN (__go_figure_handles__, , , |
|
2749 "-*- texinfo -*-\n\ |
|
2750 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ |
|
2751 Return current list of function handles.\n\ |
|
2752 @end deftypefn") |
|
2753 { |
|
2754 return octave_value (gh_manager::figure_handle_list ()); |
6406
|
2755 } |
|
2756 |
6595
|
2757 octave_value |
|
2758 get_property_from_handle (double handle, const std::string &property, |
|
2759 const std::string &func) |
|
2760 { |
|
2761 graphics_object obj = gh_manager::get_object (handle); |
|
2762 octave_value retval; |
|
2763 |
|
2764 if (obj) |
|
2765 { |
|
2766 property_name p = std::string (property); |
|
2767 retval = obj.get (p); |
|
2768 } |
|
2769 else |
|
2770 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
2771 |
|
2772 return retval; |
|
2773 } |
|
2774 |
|
2775 bool |
|
2776 set_property_in_handle (double handle, const std::string &property, |
|
2777 const octave_value &arg, const std::string &func) |
|
2778 { |
|
2779 graphics_object obj = gh_manager::get_object (handle); |
|
2780 int ret = false; |
|
2781 |
|
2782 if (obj) |
|
2783 { |
|
2784 property_name p = std::string (property); |
|
2785 obj.set (p, arg); |
|
2786 if (!error_state) |
|
2787 ret = true; |
|
2788 } |
|
2789 else |
|
2790 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
2791 |
|
2792 return ret; |
|
2793 } |
|
2794 |
6406
|
2795 /* |
|
2796 ;;; Local Variables: *** |
|
2797 ;;; mode: C++ *** |
|
2798 ;;; End: *** |
|
2799 */ |