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"), |
6809
|
980 xaxislocation ("bottom"), |
|
981 yaxislocation ("left"), |
6705
|
982 view (), |
6765
|
983 visible ("on"), |
6705
|
984 nextplot ("replace"), |
|
985 outerposition () |
|
986 { |
|
987 Matrix tlim (1, 2, 0.0); |
|
988 tlim(1) = 1; |
|
989 xlim = tlim; |
|
990 ylim = tlim; |
|
991 zlim = tlim; |
6807
|
992 Matrix cl (1, 2, 0); |
|
993 cl(1) = 1; |
|
994 clim = cl; |
6705
|
995 |
|
996 Matrix tview (1, 2, 0.0); |
|
997 tview(1) = 90; |
|
998 view = tview; |
|
999 |
|
1000 Matrix touterposition (1, 4, 0.0); |
|
1001 touterposition(2) = 1; |
|
1002 touterposition(3) = 1; |
|
1003 outerposition = touterposition; |
|
1004 } |
|
1005 |
|
1006 void |
|
1007 axes::axes_properties::set (const property_name& name, const octave_value& val) |
6406
|
1008 { |
6705
|
1009 bool modified = true; |
|
1010 |
|
1011 if (name.compare ("parent")) |
|
1012 set_parent (val); |
|
1013 else if (name.compare ("children")) |
|
1014 children = maybe_set_children (children, val); |
|
1015 else if (name.compare ("__modified__")) |
|
1016 { |
|
1017 __modified__ = val.bool_value (); |
|
1018 modified = false; |
|
1019 } |
|
1020 else if (name.compare ("position")) |
|
1021 position = val; |
|
1022 else if (name.compare ("title")) |
|
1023 { |
|
1024 graphics_handle h = ::reparent (val, "set", "title", |
|
1025 __myhandle__, false); |
|
1026 if (! error_state) |
|
1027 { |
|
1028 if (! xisnan (title)) |
|
1029 gh_manager::free (title); |
|
1030 |
|
1031 title = h; |
|
1032 } |
|
1033 } |
|
1034 else if (name.compare ("box")) |
|
1035 box = val; |
|
1036 else if (name.compare ("key")) |
|
1037 key = val; |
|
1038 else if (name.compare ("keybox")) |
|
1039 keybox = val; |
|
1040 else if (name.compare ("keypos")) |
|
1041 keypos = val; |
|
1042 else if (name.compare ("dataaspectratio")) |
|
1043 { |
|
1044 dataaspectratio = val; |
|
1045 dataaspectratiomode = "manual"; |
|
1046 } |
|
1047 else if (name.compare ("dataaspectratiomode")) |
|
1048 dataaspectratiomode = val; |
|
1049 else if (name.compare ("xlim")) |
|
1050 { |
|
1051 xlim = val; |
|
1052 xlimmode = "manual"; |
|
1053 } |
|
1054 else if (name.compare ("ylim")) |
|
1055 { |
|
1056 ylim = val; |
|
1057 ylimmode = "manual"; |
|
1058 } |
|
1059 else if (name.compare ("zlim")) |
|
1060 { |
|
1061 zlim = val; |
|
1062 zlimmode = "manual"; |
|
1063 } |
6807
|
1064 else if (name.compare ("clim")) |
|
1065 { |
|
1066 clim = val; |
|
1067 climmode = "manual"; |
|
1068 } |
6705
|
1069 else if (name.compare ("xlimmode")) |
|
1070 xlimmode = val; |
|
1071 else if (name.compare ("ylimmode")) |
|
1072 ylimmode = val; |
|
1073 else if (name.compare ("zlimmode")) |
|
1074 zlimmode = val; |
6807
|
1075 else if (name.compare ("climmode")) |
|
1076 climmode = val; |
6705
|
1077 else if (name.compare ("xlabel")) |
|
1078 { |
|
1079 graphics_handle h = ::reparent (val, "set", "xlabel", |
|
1080 __myhandle__, false); |
|
1081 if (! error_state) |
|
1082 { |
|
1083 if (! xisnan (xlabel)) |
|
1084 gh_manager::free (xlabel); |
|
1085 |
|
1086 xlabel = h; |
|
1087 } |
|
1088 } |
|
1089 else if (name.compare ("ylabel")) |
|
1090 { |
|
1091 graphics_handle h = ::reparent (val, "set", "ylabel", |
|
1092 __myhandle__, false); |
|
1093 if (! error_state) |
|
1094 { |
|
1095 if (! xisnan (ylabel)) |
|
1096 gh_manager::free (ylabel); |
|
1097 |
|
1098 ylabel = h; |
|
1099 } |
|
1100 } |
|
1101 else if (name.compare ("zlabel")) |
|
1102 { |
|
1103 graphics_handle h = ::reparent (val, "set", "zlabel", |
|
1104 __myhandle__, false); |
|
1105 if (! error_state) |
|
1106 { |
|
1107 if (! xisnan (zlabel)) |
|
1108 gh_manager::free (zlabel); |
|
1109 |
|
1110 zlabel = h; |
|
1111 } |
|
1112 } |
|
1113 else if (name.compare ("xgrid")) |
|
1114 xgrid = val; |
|
1115 else if (name.compare ("ygrid")) |
|
1116 ygrid = val; |
|
1117 else if (name.compare ("zgrid")) |
|
1118 zgrid = val; |
|
1119 else if (name.compare ("xminorgrid")) |
|
1120 xminorgrid = val; |
|
1121 else if (name.compare ("yminorgrid")) |
|
1122 yminorgrid = val; |
|
1123 else if (name.compare ("zminorgrid")) |
|
1124 zminorgrid = val; |
|
1125 else if (name.compare ("xtick")) |
|
1126 { |
|
1127 xtick = val; |
|
1128 xtickmode = "manual"; |
|
1129 } |
|
1130 else if (name.compare ("ytick")) |
6406
|
1131 { |
6705
|
1132 ytick = val; |
|
1133 ytickmode = "manual"; |
|
1134 } |
|
1135 else if (name.compare ("ztick")) |
|
1136 { |
|
1137 ztick = val; |
|
1138 ztickmode = "manual"; |
|
1139 } |
|
1140 else if (name.compare ("xtickmode")) |
|
1141 xtickmode = val; |
|
1142 else if (name.compare ("ytickmode")) |
|
1143 ytickmode = val; |
|
1144 else if (name.compare ("ztickmode")) |
|
1145 ztickmode = val; |
|
1146 else if (name.compare ("xticklabel")) |
|
1147 { |
|
1148 xticklabel = val; |
|
1149 xticklabelmode = "manual"; |
|
1150 } |
|
1151 else if (name.compare ("yticklabel")) |
|
1152 { |
|
1153 yticklabel = val; |
|
1154 yticklabelmode = "manual"; |
|
1155 } |
|
1156 else if (name.compare ("zticklabel")) |
|
1157 { |
|
1158 zticklabel = val; |
|
1159 zticklabelmode = "manual"; |
|
1160 } |
|
1161 else if (name.compare ("xticklabelmode")) |
|
1162 xticklabelmode = val; |
|
1163 else if (name.compare ("yticklabelmode")) |
|
1164 yticklabelmode = val; |
|
1165 else if (name.compare ("zticklabelmode")) |
|
1166 zticklabelmode = val; |
|
1167 else if (name.compare ("xscale")) |
|
1168 xscale = val; |
|
1169 else if (name.compare ("yscale")) |
|
1170 yscale = val; |
|
1171 else if (name.compare ("zscale")) |
|
1172 zscale = val; |
|
1173 else if (name.compare ("xdir")) |
|
1174 xdir = val; |
|
1175 else if (name.compare ("ydir")) |
|
1176 ydir = val; |
|
1177 else if (name.compare ("zdir")) |
|
1178 zdir = val; |
6809
|
1179 else if (name.compare ("xaxislocation")) |
|
1180 xaxislocation = val; |
|
1181 else if (name.compare ("yaxislocation")) |
|
1182 yaxislocation = val; |
6705
|
1183 else if (name.compare ("view")) |
|
1184 view = val; |
6765
|
1185 else if (name.compare ("visible")) |
|
1186 visible = val; |
6705
|
1187 else if (name.compare ("nextplot")) |
|
1188 nextplot = val; |
|
1189 else if (name.compare ("outerposition")) |
|
1190 outerposition = val; |
|
1191 else |
|
1192 { |
|
1193 modified = false; |
|
1194 warning ("set: invalid property `%s'", name.c_str ()); |
|
1195 } |
6406
|
1196 |
6705
|
1197 if (modified) |
|
1198 mark_modified (); |
|
1199 } |
|
1200 |
|
1201 void |
|
1202 axes::axes_properties::set_defaults (base_graphics_object& obj, |
|
1203 const std::string& mode) |
|
1204 { |
|
1205 position = Matrix (); |
|
1206 title = octave_NaN; |
|
1207 box = "on"; |
|
1208 key = "off"; |
|
1209 keybox = "off"; |
|
1210 keypos = 1; |
|
1211 dataaspectratio = Matrix (1, 3, 1.0); |
|
1212 dataaspectratiomode = "auto"; |
|
1213 |
|
1214 Matrix tlim (1, 2, 0.0); |
|
1215 tlim(1) = 1; |
|
1216 xlim = tlim; |
|
1217 ylim = tlim; |
|
1218 zlim = tlim; |
6807
|
1219 |
|
1220 Matrix cl (1, 2, 0); |
|
1221 cl(1) = 1; |
|
1222 clim = cl; |
|
1223 |
6705
|
1224 xlimmode = "auto"; |
|
1225 ylimmode = "auto"; |
|
1226 zlimmode = "auto"; |
6807
|
1227 climmode = "auto"; |
6705
|
1228 xlabel = octave_NaN; |
|
1229 ylabel = octave_NaN; |
|
1230 zlabel = octave_NaN; |
|
1231 xgrid = "off"; |
|
1232 ygrid = "off"; |
|
1233 zgrid = "off"; |
|
1234 xminorgrid = "off"; |
|
1235 yminorgrid = "off"; |
|
1236 zminorgrid = "off"; |
|
1237 xtick = Matrix (); |
|
1238 ytick = Matrix (); |
|
1239 ztick = Matrix (); |
|
1240 xtickmode = "auto"; |
|
1241 ytickmode = "auto"; |
|
1242 ztickmode = "auto"; |
|
1243 xticklabel = ""; |
|
1244 yticklabel = ""; |
|
1245 zticklabel = ""; |
|
1246 xticklabelmode = "auto"; |
|
1247 yticklabelmode = "auto"; |
|
1248 zticklabelmode = "auto"; |
|
1249 xscale = "linear"; |
|
1250 yscale = "linear"; |
|
1251 zscale = "linear"; |
|
1252 xdir = "normal"; |
|
1253 ydir = "normal"; |
|
1254 zdir = "normal"; |
6809
|
1255 xaxislocation = "left"; |
|
1256 yaxislocation = "bottom"; |
6705
|
1257 |
|
1258 Matrix tview (1, 2, 0.0); |
|
1259 tview(1) = 90; |
|
1260 view = tview; |
|
1261 |
6765
|
1262 visible = "on"; |
6705
|
1263 nextplot = "replace"; |
|
1264 |
|
1265 // FIXME -- this is not quite right; we should preserve |
|
1266 // "position" and "units". |
|
1267 |
|
1268 if (mode != "replace") |
|
1269 { |
6406
|
1270 Matrix touterposition (1, 4, 0.0); |
|
1271 touterposition(2) = 1; |
|
1272 touterposition(3) = 1; |
|
1273 outerposition = touterposition; |
|
1274 } |
|
1275 |
6705
|
1276 delete_children (); |
6406
|
1277 |
6705
|
1278 children = Matrix (); |
6432
|
1279 |
6705
|
1280 override_defaults (obj); |
|
1281 } |
|
1282 |
|
1283 octave_value |
|
1284 axes::axes_properties::get (void) const |
|
1285 { |
|
1286 Octave_map m; |
6406
|
1287 |
6705
|
1288 if (xisnan (title)) |
|
1289 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1290 |
|
1291 if (xisnan (xlabel)) |
|
1292 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1293 |
6705
|
1294 if (xisnan (ylabel)) |
|
1295 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1296 |
6705
|
1297 if (xisnan (zlabel)) |
|
1298 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
6406
|
1299 |
6705
|
1300 m.assign ("type", type); |
|
1301 m.assign ("parent", parent); |
|
1302 m.assign ("children", children); |
|
1303 m.assign ("__modified__", __modified__); |
|
1304 m.assign ("position", position); |
|
1305 m.assign ("title", title); |
|
1306 m.assign ("box", box); |
|
1307 m.assign ("key", key); |
|
1308 m.assign ("keybox", keybox); |
|
1309 m.assign ("keypos", keypos); |
|
1310 m.assign ("dataaspectratio", dataaspectratio); |
|
1311 m.assign ("dataaspectratiomode", dataaspectratiomode); |
|
1312 m.assign ("xlim", xlim); |
|
1313 m.assign ("ylim", ylim); |
|
1314 m.assign ("zlim", zlim); |
6807
|
1315 m.assign ("clim", clim); |
6705
|
1316 m.assign ("xlimmode", xlimmode); |
|
1317 m.assign ("ylimmode", ylimmode); |
|
1318 m.assign ("zlimmode", zlimmode); |
6807
|
1319 m.assign ("climmode", climmode); |
6705
|
1320 m.assign ("xlabel", xlabel); |
|
1321 m.assign ("ylabel", ylabel); |
|
1322 m.assign ("zlabel", zlabel); |
|
1323 m.assign ("xgrid", xgrid); |
|
1324 m.assign ("ygrid", ygrid); |
|
1325 m.assign ("zgrid", zgrid); |
|
1326 m.assign ("xminorgrid", xminorgrid); |
|
1327 m.assign ("yminorgrid", yminorgrid); |
|
1328 m.assign ("zminorgrid", zminorgrid); |
|
1329 m.assign ("xtick", xtick); |
|
1330 m.assign ("ytick", ytick); |
|
1331 m.assign ("ztick", ztick); |
|
1332 m.assign ("xtickmode", xtickmode); |
|
1333 m.assign ("ytickmode", ytickmode); |
|
1334 m.assign ("ztickmode", ztickmode); |
|
1335 m.assign ("xticklabel", xticklabel); |
|
1336 m.assign ("yticklabel", yticklabel); |
|
1337 m.assign ("zticklabel", zticklabel); |
|
1338 m.assign ("xticklabelmode", xticklabelmode); |
|
1339 m.assign ("yticklabelmode", yticklabelmode); |
|
1340 m.assign ("zticklabelmode", zticklabelmode); |
|
1341 m.assign ("xscale", xscale); |
|
1342 m.assign ("yscale", yscale); |
|
1343 m.assign ("zscale", zscale); |
|
1344 m.assign ("xdir", xdir); |
|
1345 m.assign ("ydir", ydir); |
|
1346 m.assign ("zdir", zdir); |
6809
|
1347 m.assign ("xaxislocation", xaxislocation); |
|
1348 m.assign ("yaxislocation", yaxislocation); |
6705
|
1349 m.assign ("view", view); |
6765
|
1350 m.assign ("visible", visible); |
6705
|
1351 m.assign ("nextplot", nextplot); |
|
1352 m.assign ("outerposition", outerposition); |
6432
|
1353 |
6705
|
1354 return m; |
|
1355 } |
6406
|
1356 |
6705
|
1357 octave_value |
|
1358 axes::axes_properties::get (const property_name& name) const |
|
1359 { |
|
1360 octave_value retval; |
6406
|
1361 |
6705
|
1362 if (name.compare ("type")) |
|
1363 retval = type; |
|
1364 else if (name.compare ("parent")) |
|
1365 retval = parent; |
|
1366 else if (name.compare ("children")) |
|
1367 retval = children; |
|
1368 else if (name.compare ("__modified__")) |
|
1369 retval = __modified__; |
|
1370 else if (name.compare ("position")) |
|
1371 retval = position; |
|
1372 else if (name.compare ("title")) |
6406
|
1373 { |
|
1374 if (xisnan (title)) |
|
1375 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1376 |
6705
|
1377 retval = title; |
|
1378 } |
|
1379 else if (name.compare ("box")) |
|
1380 retval = box; |
|
1381 else if (name.compare ("key")) |
|
1382 retval = key; |
|
1383 else if (name.compare ("keybox")) |
|
1384 retval = keybox; |
|
1385 else if (name.compare ("keypos")) |
|
1386 retval = keypos; |
|
1387 else if (name.compare ("dataaspectratio")) |
|
1388 retval = dataaspectratio; |
|
1389 else if (name.compare ("dataaspectratiomode")) |
|
1390 retval = dataaspectratiomode; |
|
1391 else if (name.compare ("xlim")) |
|
1392 retval = xlim; |
|
1393 else if (name.compare ("ylim")) |
|
1394 retval = ylim; |
|
1395 else if (name.compare ("zlim")) |
|
1396 retval = zlim; |
6807
|
1397 else if (name.compare ("clim")) |
|
1398 retval = clim; |
6705
|
1399 else if (name.compare ("xlimmode")) |
|
1400 retval = xlimmode; |
|
1401 else if (name.compare ("ylimmode")) |
|
1402 retval = ylimmode; |
|
1403 else if (name.compare ("zlimmode")) |
|
1404 retval = zlimmode; |
6807
|
1405 else if (name.compare ("climmode")) |
|
1406 retval = climmode; |
6705
|
1407 else if (name.compare ("xlabel")) |
|
1408 { |
6406
|
1409 if (xisnan (xlabel)) |
|
1410 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1411 |
6705
|
1412 retval = xlabel; |
|
1413 } |
|
1414 else if (name.compare ("ylabel")) |
|
1415 { |
6406
|
1416 if (xisnan (ylabel)) |
|
1417 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1418 |
6705
|
1419 retval = ylabel; |
|
1420 } |
|
1421 else if (name.compare ("zlabel")) |
|
1422 { |
6406
|
1423 if (xisnan (zlabel)) |
|
1424 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1425 |
6705
|
1426 retval = zlabel; |
6406
|
1427 } |
6705
|
1428 else if (name.compare ("xgrid")) |
|
1429 retval = xgrid; |
|
1430 else if (name.compare ("ygrid")) |
|
1431 retval = ygrid; |
|
1432 else if (name.compare ("zgrid")) |
|
1433 retval = zgrid; |
|
1434 else if (name.compare ("xminorgrid")) |
|
1435 retval = xminorgrid; |
|
1436 else if (name.compare ("yminorgrid")) |
|
1437 retval = yminorgrid; |
|
1438 else if (name.compare ("zminorgrid")) |
|
1439 retval = zminorgrid; |
|
1440 else if (name.compare ("xtick")) |
|
1441 retval = xtick; |
|
1442 else if (name.compare ("ytick")) |
|
1443 retval = ytick; |
|
1444 else if (name.compare ("ztick")) |
|
1445 retval = ztick; |
|
1446 else if (name.compare ("xtickmode")) |
|
1447 retval = xtickmode; |
|
1448 else if (name.compare ("ytickmode")) |
|
1449 retval = ytickmode; |
|
1450 else if (name.compare ("ztickmode")) |
|
1451 retval = ztickmode; |
|
1452 else if (name.compare ("xticklabel")) |
|
1453 retval = xticklabel; |
|
1454 else if (name.compare ("yticklabel")) |
|
1455 retval = yticklabel; |
|
1456 else if (name.compare ("zticklabel")) |
|
1457 retval = zticklabel; |
|
1458 else if (name.compare ("xticklabelmode")) |
|
1459 retval = xticklabelmode; |
|
1460 else if (name.compare ("yticklabelmode")) |
|
1461 retval = yticklabelmode; |
|
1462 else if (name.compare ("zticklabelmode")) |
|
1463 retval = zticklabelmode; |
|
1464 else if (name.compare ("xscale")) |
|
1465 retval = xscale; |
|
1466 else if (name.compare ("yscale")) |
|
1467 retval = yscale; |
|
1468 else if (name.compare ("zscale")) |
|
1469 retval = zscale; |
|
1470 else if (name.compare ("xdir")) |
|
1471 retval = xdir; |
|
1472 else if (name.compare ("ydir")) |
|
1473 retval = ydir; |
|
1474 else if (name.compare ("zdir")) |
|
1475 retval = zdir; |
6809
|
1476 else if (name.compare ("xaxislocation")) |
|
1477 retval = xaxislocation; |
|
1478 else if (name.compare ("yaxislocation")) |
|
1479 retval = yaxislocation; |
6705
|
1480 else if (name.compare ("view")) |
|
1481 retval = view; |
6765
|
1482 else if (name.compare ("visible")) |
|
1483 retval = visible; |
6705
|
1484 else if (name.compare ("nextplot")) |
|
1485 retval = nextplot; |
|
1486 else if (name.compare ("outerposition")) |
|
1487 retval = outerposition; |
|
1488 else |
|
1489 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1490 |
6705
|
1491 return retval; |
|
1492 } |
6406
|
1493 |
6705
|
1494 void |
|
1495 axes::axes_properties::remove_child (const graphics_handle& h) |
|
1496 { |
|
1497 if (! xisnan (title) && h == title) |
|
1498 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1499 else if (! xisnan (xlabel) && h == xlabel) |
|
1500 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1501 else if (! xisnan (ylabel) && h == ylabel) |
|
1502 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1503 else if (! xisnan (zlabel) && h == zlabel) |
|
1504 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1505 else |
|
1506 base_properties::remove_child (h); |
|
1507 } |
6406
|
1508 |
6705
|
1509 void |
|
1510 axes::axes_properties::delete_children (void) |
|
1511 { |
|
1512 base_properties::delete_children (); |
|
1513 |
|
1514 if (! xisnan (title)) |
|
1515 gh_manager::free (title); |
6406
|
1516 |
6705
|
1517 if (! xisnan (xlabel)) |
|
1518 gh_manager::free (xlabel); |
6406
|
1519 |
6705
|
1520 if (! xisnan (ylabel)) |
|
1521 gh_manager::free (ylabel); |
6406
|
1522 |
6705
|
1523 if (! xisnan (zlabel)) |
|
1524 gh_manager::free (zlabel); |
|
1525 } |
6406
|
1526 |
6705
|
1527 property_list::pval_map_type axes::axes_properties::factory_defaults (void) |
|
1528 { |
|
1529 property_list::pval_map_type m; |
6406
|
1530 |
6705
|
1531 m["position"] = Matrix (); |
|
1532 m["title"] = octave_NaN; |
|
1533 m["box"] = "on"; |
|
1534 m["key"] = "off"; |
|
1535 m["keybox"] = "off"; |
|
1536 m["keypos"] = 1; |
|
1537 m["dataaspectratio"] = Matrix (1, 3, 1.0); |
|
1538 m["dataaspectratiomode"] = "auto"; |
6406
|
1539 |
6705
|
1540 Matrix tlim (1, 2, 0.0); |
|
1541 tlim(1) = 1; |
6406
|
1542 |
6705
|
1543 m["xlim"] = tlim; |
|
1544 m["ylim"] = tlim; |
|
1545 m["zlim"] = tlim; |
6807
|
1546 |
|
1547 Matrix cl(1, 2, 0); |
|
1548 cl(1) = 1; |
|
1549 |
|
1550 m["clim"] = cl; |
6406
|
1551 |
6705
|
1552 m["xlimmode"] = "auto"; |
|
1553 m["ylimmode"] = "auto"; |
|
1554 m["zlimmode"] = "auto"; |
6807
|
1555 m["climmode"] = "auto"; |
6705
|
1556 m["xlabel"] = octave_NaN; |
|
1557 m["ylabel"] = octave_NaN; |
|
1558 m["zlabel"] = octave_NaN; |
|
1559 m["xgrid"] = "off"; |
|
1560 m["ygrid"] = "off"; |
|
1561 m["zgrid"] = "off"; |
|
1562 m["xminorgrid"] = "off"; |
|
1563 m["yminorgrid"] = "off"; |
|
1564 m["zminorgrid"] = "off"; |
|
1565 m["xtick"] = Matrix (); |
|
1566 m["ytick"] = Matrix (); |
|
1567 m["ztick"] = Matrix (); |
|
1568 m["xtickmode"] = "auto"; |
|
1569 m["ytickmode"] = "auto"; |
|
1570 m["ztickmode"] = "auto"; |
|
1571 m["xticklabel"] = ""; |
|
1572 m["yticklabel"] = ""; |
|
1573 m["zticklabel"] = ""; |
|
1574 m["xticklabelmode"] = "auto"; |
|
1575 m["yticklabelmode"] = "auto"; |
|
1576 m["zticklabelmode"] = "auto"; |
|
1577 m["xscale"] = "linear"; |
|
1578 m["yscale"] = "linear"; |
|
1579 m["zscale"] = "linear"; |
|
1580 m["xdir"] = "normal"; |
|
1581 m["ydir"] = "normal"; |
|
1582 m["zdir"] = "normal"; |
6809
|
1583 m["xaxislocation"] = "bottom"; |
|
1584 m["yaxislocation"] = "left"; |
6406
|
1585 |
6705
|
1586 Matrix tview (1, 2, 0.0); |
|
1587 tview(1) = 90; |
6406
|
1588 |
6705
|
1589 m["view"] = tview; |
6406
|
1590 |
6765
|
1591 m["visible"] = "on"; |
6705
|
1592 m["nextplot"] = "replace"; |
6406
|
1593 |
6705
|
1594 Matrix touterposition (1, 4, 0.0); |
|
1595 touterposition(2) = 1; |
|
1596 touterposition(3) = 1; |
6406
|
1597 |
6705
|
1598 m["outerposition"] = touterposition; |
6406
|
1599 |
6705
|
1600 return m; |
|
1601 } |
6406
|
1602 |
|
1603 std::string axes::axes_properties::go_name ("axes"); |
|
1604 |
|
1605 // --------------------------------------------------------------------- |
|
1606 |
|
1607 static Matrix |
|
1608 default_data (void) |
|
1609 { |
|
1610 Matrix retval (1, 2); |
|
1611 |
|
1612 retval(0) = 0; |
|
1613 retval(1) = 1; |
|
1614 |
|
1615 return retval; |
|
1616 } |
|
1617 |
6705
|
1618 line::line_properties::line_properties (const graphics_handle& mh, |
|
1619 const graphics_handle& p) |
|
1620 : base_properties (go_name, mh, p), |
|
1621 xdata (default_data ()), |
|
1622 ydata (default_data ()), |
|
1623 zdata (Matrix ()), |
|
1624 ldata (Matrix ()), |
|
1625 udata (Matrix ()), |
|
1626 xldata (Matrix ()), |
|
1627 xudata (Matrix ()), |
|
1628 color (), |
|
1629 linestyle ("-"), |
|
1630 linewidth (0.5), |
|
1631 marker ("none"), |
|
1632 markeredgecolor ("auto"), |
|
1633 markerfacecolor ("none"), |
|
1634 markersize (1), |
|
1635 keylabel ("") |
|
1636 { } |
|
1637 |
|
1638 void |
|
1639 line::line_properties::set (const property_name& name, const octave_value& val) |
6406
|
1640 { |
6705
|
1641 bool modified = true; |
6432
|
1642 |
6705
|
1643 if (name.compare ("parent")) |
|
1644 set_parent (val); |
|
1645 else if (name.compare ("children")) |
|
1646 children = maybe_set_children (children, val); |
|
1647 else if (name.compare ("__modified__")) |
|
1648 { |
|
1649 __modified__ = val.bool_value (); |
|
1650 modified = false; |
6406
|
1651 } |
6705
|
1652 else if (name.compare ("xdata")) |
|
1653 xdata = val; |
|
1654 else if (name.compare ("ydata")) |
|
1655 ydata = val; |
|
1656 else if (name.compare ("zdata")) |
|
1657 zdata = val; |
|
1658 else if (name.compare ("ldata")) |
|
1659 ldata = val; |
|
1660 else if (name.compare ("udata")) |
|
1661 udata = val; |
|
1662 else if (name.compare ("xldata")) |
|
1663 xldata = val; |
|
1664 else if (name.compare ("xudata")) |
|
1665 xudata = val; |
|
1666 else if (name.compare ("color")) |
6790
|
1667 color = val; |
6705
|
1668 else if (name.compare ("linestyle")) |
|
1669 linestyle = val; |
|
1670 else if (name.compare ("linewidth")) |
|
1671 linewidth = val; |
|
1672 else if (name.compare ("marker")) |
|
1673 marker = val; |
|
1674 else if (name.compare ("markeredgecolor")) |
|
1675 markeredgecolor = val; |
|
1676 else if (name.compare ("markerfacecolor")) |
|
1677 markerfacecolor = val; |
|
1678 else if (name.compare ("markersize")) |
|
1679 markersize = val; |
|
1680 else if (name.compare ("keylabel")) |
|
1681 keylabel = val; |
|
1682 else |
6406
|
1683 { |
6705
|
1684 modified = false; |
|
1685 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1686 } |
|
1687 |
6705
|
1688 if (modified) |
|
1689 mark_modified (); |
|
1690 } |
|
1691 |
|
1692 octave_value |
|
1693 line::line_properties::get (void) const |
|
1694 { |
|
1695 Octave_map m; |
6406
|
1696 |
6705
|
1697 m.assign ("type", type); |
|
1698 m.assign ("parent", parent); |
|
1699 m.assign ("children", children); |
|
1700 m.assign ("__modified__", __modified__); |
|
1701 m.assign ("xdata", xdata); |
|
1702 m.assign ("ydata", ydata); |
|
1703 m.assign ("zdata", zdata); |
|
1704 m.assign ("ldata", ldata); |
|
1705 m.assign ("udata", udata); |
|
1706 m.assign ("xldata", xldata); |
|
1707 m.assign ("xudata", xudata); |
|
1708 m.assign ("color", color); |
|
1709 m.assign ("linestyle", linestyle); |
|
1710 m.assign ("linewidth", linewidth); |
|
1711 m.assign ("marker", marker); |
|
1712 m.assign ("markeredgecolor", markeredgecolor); |
|
1713 m.assign ("markerface", markerfacecolor); |
|
1714 m.assign ("markersize", markersize); |
|
1715 m.assign ("keylabel", keylabel); |
6406
|
1716 |
6705
|
1717 return m; |
|
1718 } |
6406
|
1719 |
6705
|
1720 octave_value |
|
1721 line::line_properties::get (const property_name& name) const |
|
1722 { |
|
1723 octave_value retval; |
6406
|
1724 |
6705
|
1725 if (name.compare ("type")) |
|
1726 retval = type; |
|
1727 else if (name.compare ("parent")) |
|
1728 retval = parent; |
|
1729 else if (name.compare ("children")) |
|
1730 retval = children; |
|
1731 else if (name.compare ("__modified__")) |
|
1732 retval = __modified__; |
|
1733 else if (name.compare ("xdata")) |
|
1734 retval = xdata; |
|
1735 else if (name.compare ("ydata")) |
|
1736 retval = ydata; |
|
1737 else if (name.compare ("zdata")) |
|
1738 retval = zdata; |
|
1739 else if (name.compare ("ldata")) |
|
1740 retval = ldata; |
|
1741 else if (name.compare ("udata")) |
|
1742 retval = udata; |
|
1743 else if (name.compare ("xldata")) |
|
1744 retval = xldata; |
|
1745 else if (name.compare ("xudata")) |
|
1746 retval = xudata; |
|
1747 else if (name.compare ("color")) |
|
1748 retval = color; |
|
1749 else if (name.compare ("linestyle")) |
|
1750 retval = linestyle; |
|
1751 else if (name.compare ("linewidth")) |
|
1752 retval = linewidth; |
|
1753 else if (name.compare ("marker")) |
|
1754 retval = marker; |
|
1755 else if (name.compare ("markeredgecolor")) |
|
1756 retval = markeredgecolor; |
|
1757 else if (name.compare ("markerfacecolor")) |
|
1758 retval = markerfacecolor; |
|
1759 else if (name.compare ("markersize")) |
|
1760 retval = markersize; |
|
1761 else if (name.compare ("keylabel")) |
|
1762 retval = keylabel; |
|
1763 else |
|
1764 warning ("get: invalid property `%s'", name.c_str ()); |
6432
|
1765 |
6705
|
1766 return retval; |
|
1767 } |
6406
|
1768 |
6705
|
1769 property_list::pval_map_type line::line_properties::factory_defaults (void) |
|
1770 { |
|
1771 property_list::pval_map_type m; |
6406
|
1772 |
6705
|
1773 m["xdata"] = default_data (); |
|
1774 m["ydata"] = default_data (); |
|
1775 m["zdata"] = Matrix (); |
|
1776 m["ldata"] = Matrix (); |
|
1777 m["udata"] = Matrix (); |
|
1778 m["xldata"] = Matrix (); |
|
1779 m["xudata"] = Matrix (); |
|
1780 m["color"] = color_property (); |
|
1781 m["linestyle"] = "-"; |
|
1782 m["linewidth"] = 0.5; |
|
1783 m["marker"] = "none"; |
|
1784 m["markeredgecolor"] = "auto"; |
|
1785 m["markerfacecolor"] = "none"; |
|
1786 m["markersize"] = 1; |
|
1787 m["keylabel"] = ""; |
6406
|
1788 |
6705
|
1789 return m; |
|
1790 } |
6406
|
1791 |
|
1792 std::string line::line_properties::go_name ("line"); |
|
1793 |
|
1794 // --------------------------------------------------------------------- |
|
1795 |
6705
|
1796 text::text_properties::text_properties (const graphics_handle& mh, |
|
1797 const graphics_handle& p) |
|
1798 : base_properties (go_name, mh, p), |
|
1799 string (""), |
|
1800 units ("data"), |
|
1801 position (Matrix (1, 3, 0.0)), |
6724
|
1802 rotation (0), |
6829
|
1803 horizontalalignment ("left"), |
|
1804 color (Matrix (1, 3, 1.0)) |
6705
|
1805 { } |
|
1806 |
|
1807 void |
|
1808 text::text_properties::set (const property_name& name, const octave_value& val) |
6406
|
1809 { |
6705
|
1810 bool modified = true; |
6432
|
1811 |
6705
|
1812 if (name.compare ("parent")) |
|
1813 set_parent (val); |
|
1814 else if (name.compare ("children")) |
|
1815 children = maybe_set_children (children, val); |
|
1816 else if (name.compare ("__modified__")) |
|
1817 { |
|
1818 __modified__ = val.bool_value (); |
|
1819 modified = false; |
6406
|
1820 } |
6705
|
1821 else if (name.compare ("string")) |
|
1822 string = val; |
|
1823 else if (name.compare ("units")) |
|
1824 units = val; |
|
1825 else if (name.compare ("position")) |
|
1826 position = val; |
6724
|
1827 else if (name.compare ("rotation")) |
|
1828 rotation = val; |
6705
|
1829 else if (name.compare ("horizontalalignment")) |
|
1830 horizontalalignment = val; |
6829
|
1831 else if (name.compare ("color")) |
|
1832 color = val; |
6705
|
1833 else |
6406
|
1834 { |
6705
|
1835 modified = false; |
|
1836 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1837 } |
|
1838 |
6705
|
1839 if (modified) |
|
1840 mark_modified (); |
|
1841 } |
6406
|
1842 |
6705
|
1843 octave_value |
|
1844 text::text_properties::get (void) const |
|
1845 { |
|
1846 Octave_map m; |
6406
|
1847 |
6705
|
1848 m.assign ("type", type); |
|
1849 m.assign ("parent", parent); |
|
1850 m.assign ("children", children); |
|
1851 m.assign ("__modified__", __modified__); |
|
1852 m.assign ("string", string); |
|
1853 m.assign ("units", units); |
|
1854 m.assign ("position", position); |
6724
|
1855 m.assign ("rotation", rotation); |
6705
|
1856 m.assign ("horizontalalignment", horizontalalignment); |
6829
|
1857 m.assign ("color", color); |
6406
|
1858 |
6705
|
1859 return m; |
|
1860 } |
6406
|
1861 |
6705
|
1862 octave_value |
|
1863 text::text_properties::get (const property_name& name) const |
|
1864 { |
|
1865 octave_value retval; |
6406
|
1866 |
6705
|
1867 if (name.compare ("type")) |
|
1868 retval = type; |
|
1869 else if (name.compare ("parent")) |
|
1870 retval = parent; |
|
1871 else if (name.compare ("children")) |
|
1872 retval = children; |
|
1873 else if (name.compare ("__modified__")) |
|
1874 retval = __modified__; |
|
1875 else if (name.compare ("string")) |
|
1876 retval = string; |
|
1877 else if (name.compare ("units")) |
|
1878 retval = units; |
|
1879 else if (name.compare ("position")) |
|
1880 retval = position; |
6724
|
1881 else if (name.compare ("rotation")) |
|
1882 retval = rotation; |
6705
|
1883 else if (name.compare ("horizontalalignment")) |
|
1884 retval = horizontalalignment; |
6829
|
1885 else if (name.compare ("color")) |
|
1886 retval = color; |
6705
|
1887 else |
|
1888 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1889 |
6705
|
1890 return retval; |
|
1891 } |
6406
|
1892 |
6705
|
1893 property_list::pval_map_type |
|
1894 text::text_properties::factory_defaults (void) |
|
1895 { |
|
1896 property_list::pval_map_type m; |
6406
|
1897 |
6705
|
1898 m["string"] = ""; |
|
1899 m["units"] = "data"; |
|
1900 m["position"] = Matrix (1, 3, 0.0); |
6724
|
1901 m["rotation"] = 0; |
6705
|
1902 m["horizontalalignment"] = "left"; |
6829
|
1903 m["color"] = Matrix (1, 3, 1.0); |
6406
|
1904 |
6705
|
1905 return m; |
|
1906 } |
6406
|
1907 |
|
1908 std::string text::text_properties::go_name ("text"); |
|
1909 |
|
1910 // --------------------------------------------------------------------- |
|
1911 |
6705
|
1912 image::image_properties::image_properties (const graphics_handle& mh, |
|
1913 const graphics_handle& p) |
|
1914 : base_properties (go_name, mh, p), |
|
1915 cdata (Matrix ()), |
|
1916 xdata (Matrix ()), |
|
1917 ydata (Matrix ()) |
|
1918 { } |
|
1919 |
|
1920 void |
|
1921 image::image_properties::set (const property_name& name, |
|
1922 const octave_value& val) |
6406
|
1923 { |
6705
|
1924 bool modified = true; |
6432
|
1925 |
6705
|
1926 if (name.compare ("parent")) |
|
1927 set_parent (val); |
|
1928 else if (name.compare ("children")) |
|
1929 children = maybe_set_children (children, val); |
|
1930 else if (name.compare ("__modified__")) |
|
1931 { |
|
1932 __modified__ = val.bool_value (); |
|
1933 modified = false; |
6406
|
1934 } |
6705
|
1935 else if (name.compare ("cdata")) |
|
1936 cdata = val; |
|
1937 else if (name.compare ("xdata")) |
|
1938 xdata = val; |
|
1939 else if (name.compare ("ydata")) |
|
1940 ydata = val; |
|
1941 else |
6406
|
1942 { |
6705
|
1943 modified = false; |
|
1944 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1945 } |
|
1946 |
6705
|
1947 if (modified) |
|
1948 mark_modified (); |
|
1949 } |
6406
|
1950 |
6705
|
1951 octave_value |
|
1952 image::image_properties::get (void) const |
|
1953 { |
|
1954 Octave_map m; |
6406
|
1955 |
6705
|
1956 m.assign ("type", type); |
|
1957 m.assign ("parent", parent); |
|
1958 m.assign ("children", children); |
|
1959 m.assign ("__modified__", __modified__); |
|
1960 m.assign ("cdata", cdata); |
|
1961 m.assign ("xdata", xdata); |
|
1962 m.assign ("ydata", ydata); |
6406
|
1963 |
6705
|
1964 return m; |
|
1965 } |
6406
|
1966 |
6705
|
1967 octave_value |
|
1968 image::image_properties::get (const property_name& name) const |
|
1969 { |
|
1970 octave_value retval; |
6406
|
1971 |
6705
|
1972 if (name.compare ("type")) |
|
1973 retval = type; |
|
1974 else if (name.compare ("parent")) |
|
1975 retval = parent; |
|
1976 else if (name.compare ("children")) |
|
1977 retval = children; |
|
1978 else if (name.compare ("__modified__")) |
|
1979 retval = __modified__; |
|
1980 else if (name.compare ("cdata")) |
|
1981 retval = cdata; |
|
1982 else if (name.compare ("xdata")) |
|
1983 retval = xdata; |
|
1984 else if (name.compare ("ydata")) |
|
1985 retval = ydata; |
|
1986 else |
|
1987 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1988 |
6705
|
1989 return retval; |
|
1990 } |
6406
|
1991 |
6705
|
1992 property_list::pval_map_type image::image_properties::factory_defaults (void) |
|
1993 { |
|
1994 property_list::pval_map_type m; |
6406
|
1995 |
6705
|
1996 m["cdata"] = Matrix (); |
|
1997 m["xdata"] = Matrix (); |
|
1998 m["ydata"] = Matrix (); |
6406
|
1999 |
6705
|
2000 return m; |
|
2001 } |
6406
|
2002 |
|
2003 std::string image::image_properties::go_name ("image"); |
|
2004 |
|
2005 // --------------------------------------------------------------------- |
|
2006 |
6807
|
2007 patch::patch_properties::patch_properties (const graphics_handle& mh, |
|
2008 const graphics_handle& p) |
|
2009 : base_properties (go_name, mh, p), |
|
2010 cdata (Matrix ()), |
|
2011 xdata (Matrix ()), |
|
2012 ydata (Matrix ()), |
|
2013 zdata (Matrix ()), |
|
2014 facecolor (radio_values("{flat}|none|interp")), |
|
2015 facealpha (1.0), |
|
2016 edgecolor (color_values(0, 0, 0), radio_values("flat|none|interp")), |
|
2017 linestyle ("-"), |
|
2018 linewidth (0.5), |
|
2019 marker ("none"), |
|
2020 markeredgecolor ("auto"), |
|
2021 markerfacecolor ("none"), |
|
2022 markersize (1) |
|
2023 { } |
|
2024 |
|
2025 void |
|
2026 patch::patch_properties::set (const property_name& name, |
|
2027 const octave_value& val) |
|
2028 { |
|
2029 bool modified = true; |
|
2030 |
|
2031 if (name.compare ("parent")) |
|
2032 set_parent (val); |
|
2033 else if (name.compare ("children")) |
|
2034 children = maybe_set_children (children, val); |
|
2035 else if (name.compare ("__modified__")) |
|
2036 { |
|
2037 __modified__ = val.bool_value (); |
|
2038 modified = false; |
|
2039 } |
|
2040 else if (name.compare ("cdata")) |
|
2041 cdata = val; |
|
2042 else if (name.compare ("xdata")) |
|
2043 xdata = val; |
|
2044 else if (name.compare ("ydata")) |
|
2045 ydata = val; |
|
2046 else if (name.compare ("zdata")) |
|
2047 zdata = val; |
|
2048 else if (name.compare ("facecolor")) |
|
2049 facecolor = val; |
|
2050 else if (name.compare ("facealpha")) |
|
2051 facealpha = val; |
|
2052 else if (name.compare ("edgecolor")) |
|
2053 edgecolor = val; |
|
2054 else if (name.compare ("linestyle")) |
|
2055 linestyle = val; |
|
2056 else if (name.compare ("linewidth")) |
|
2057 linewidth = val; |
|
2058 else if (name.compare ("marker")) |
|
2059 marker = val; |
|
2060 else if (name.compare ("markeredgecolor")) |
|
2061 markeredgecolor = val; |
|
2062 else if (name.compare ("markerfacecolor")) |
|
2063 markerfacecolor = val; |
|
2064 else if (name.compare ("markersize")) |
|
2065 markersize = val; |
|
2066 |
|
2067 else |
|
2068 { |
|
2069 modified = false; |
|
2070 warning ("set: invalid property `%s'", name.c_str ()); |
|
2071 } |
|
2072 |
|
2073 if (modified) |
|
2074 mark_modified (); |
|
2075 } |
|
2076 |
|
2077 octave_value |
|
2078 patch::patch_properties::get (void) const |
|
2079 { |
|
2080 Octave_map m; |
|
2081 |
|
2082 m.assign ("type", type); |
|
2083 m.assign ("parent", parent); |
|
2084 m.assign ("children", children); |
|
2085 m.assign ("__modified__", __modified__); |
|
2086 m.assign ("cdata", cdata); |
|
2087 m.assign ("xdata", xdata); |
|
2088 m.assign ("ydata", ydata); |
|
2089 m.assign ("zdata", zdata); |
|
2090 m.assign ("facecolor", facecolor); |
|
2091 m.assign ("facealpha", facealpha); |
|
2092 m.assign ("edgecolor", edgecolor); |
|
2093 m.assign ("linestyle", linestyle); |
|
2094 m.assign ("linewidth", linewidth); |
|
2095 m.assign ("marker", marker); |
|
2096 m.assign ("markeredgecolor", markeredgecolor); |
|
2097 m.assign ("markerface", markerfacecolor); |
|
2098 m.assign ("markersize", markersize); |
|
2099 |
|
2100 return m; |
|
2101 } |
|
2102 |
|
2103 octave_value |
|
2104 patch::patch_properties::get (const property_name& name) const |
|
2105 { |
|
2106 octave_value retval; |
|
2107 |
|
2108 if (name.compare ("type")) |
|
2109 retval = type; |
|
2110 else if (name.compare ("parent")) |
|
2111 retval = parent; |
|
2112 else if (name.compare ("children")) |
|
2113 retval = children; |
|
2114 else if (name.compare ("__modified__")) |
|
2115 retval = __modified__; |
|
2116 else if (name.compare ("cdata")) |
|
2117 retval = cdata; |
|
2118 else if (name.compare ("xdata")) |
|
2119 retval = xdata; |
|
2120 else if (name.compare ("ydata")) |
|
2121 retval = ydata; |
|
2122 else if (name.compare ("zdata")) |
|
2123 retval = zdata; |
|
2124 else if (name.compare ("facecolor")) |
|
2125 retval = facecolor; |
|
2126 else if (name.compare ("facealpha")) |
|
2127 retval = facecolor; |
|
2128 else if (name.compare ("egdecolor")) |
|
2129 retval = edgecolor; |
|
2130 else if (name.compare ("linestyle")) |
|
2131 retval = linestyle; |
|
2132 else if (name.compare ("linewidth")) |
|
2133 retval = linewidth; |
|
2134 else if (name.compare ("marker")) |
|
2135 retval = marker; |
|
2136 else if (name.compare ("markeredgecolor")) |
|
2137 retval = markeredgecolor; |
|
2138 else if (name.compare ("markerfacecolor")) |
|
2139 retval = markerfacecolor; |
|
2140 else if (name.compare ("markersize")) |
|
2141 retval = markersize; |
|
2142 else |
|
2143 warning ("get: invalid property `%s'", name.c_str ()); |
|
2144 |
|
2145 return retval; |
|
2146 } |
|
2147 |
|
2148 property_list::pval_map_type patch::patch_properties::factory_defaults (void) |
|
2149 { |
|
2150 property_list::pval_map_type m; |
|
2151 |
|
2152 m["cdata"] = Matrix (); |
|
2153 m["xdata"] = Matrix (); |
|
2154 m["ydata"] = Matrix (); |
|
2155 m["zdata"] = Matrix (); |
|
2156 m["facecolor"] = color_property(); |
|
2157 m["facealpha"] = 1.0; |
|
2158 m["edgecolor"] = color_property("black"); |
|
2159 m["linestyle"] = "-"; |
|
2160 m["linewidth"] = 0.5; |
|
2161 m["marker"] = "none"; |
|
2162 m["markeredgecolor"] = "auto"; |
|
2163 m["markerfacecolor"] = "none"; |
|
2164 m["markersize"] = 1; |
|
2165 |
|
2166 |
|
2167 return m; |
|
2168 } |
|
2169 |
|
2170 std::string patch::patch_properties::go_name ("patch"); |
|
2171 |
|
2172 // --------------------------------------------------------------------- |
|
2173 |
6705
|
2174 surface::surface_properties::surface_properties (const graphics_handle& mh, |
|
2175 const graphics_handle& p) |
|
2176 : base_properties (go_name, mh, p), |
|
2177 xdata (Matrix ()), |
|
2178 ydata (Matrix ()), |
|
2179 zdata (Matrix ()), |
|
2180 keylabel ("") |
|
2181 { } |
|
2182 |
|
2183 void |
|
2184 surface::surface_properties::set (const property_name& name, |
|
2185 const octave_value& val) |
6406
|
2186 { |
6705
|
2187 bool modified = true; |
6432
|
2188 |
6705
|
2189 if (name.compare ("parent")) |
|
2190 set_parent (val); |
|
2191 else if (name.compare ("children")) |
|
2192 children = maybe_set_children (children, val); |
|
2193 else if (name.compare ("__modified__")) |
|
2194 { |
|
2195 __modified__ = val.bool_value (); |
|
2196 modified = false; |
6406
|
2197 } |
6705
|
2198 else if (name.compare ("xdata")) |
|
2199 xdata = val; |
|
2200 else if (name.compare ("ydata")) |
|
2201 ydata = val; |
|
2202 else if (name.compare ("zdata")) |
|
2203 zdata = val; |
|
2204 else if (name.compare ("keylabel")) |
|
2205 keylabel = val; |
|
2206 else |
6406
|
2207 { |
6705
|
2208 modified = false; |
|
2209 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2210 } |
|
2211 |
6705
|
2212 if (modified) |
|
2213 mark_modified (); |
|
2214 } |
6406
|
2215 |
6705
|
2216 octave_value |
|
2217 surface::surface_properties::get (void) const |
|
2218 { |
|
2219 Octave_map m; |
6406
|
2220 |
6705
|
2221 m.assign ("type", type); |
|
2222 m.assign ("parent", parent); |
|
2223 m.assign ("children", children); |
|
2224 m.assign ("__modified__", __modified__); |
|
2225 m.assign ("xdata", xdata); |
|
2226 m.assign ("ydata", ydata); |
|
2227 m.assign ("zdata", zdata); |
|
2228 m.assign ("keylabel", keylabel); |
6406
|
2229 |
6705
|
2230 return m; |
|
2231 } |
6406
|
2232 |
6705
|
2233 octave_value |
|
2234 surface::surface_properties::get (const property_name& name) const |
|
2235 { |
|
2236 octave_value retval; |
6406
|
2237 |
6705
|
2238 if (name.compare ("type")) |
|
2239 retval = type; |
|
2240 else if (name.compare ("parent")) |
|
2241 retval = parent; |
|
2242 else if (name.compare ("children")) |
|
2243 retval = children; |
|
2244 else if (name.compare ("__modified__")) |
|
2245 retval = __modified__; |
|
2246 else if (name.compare ("xdata")) |
|
2247 retval = xdata; |
|
2248 else if (name.compare ("ydata")) |
|
2249 retval = ydata; |
|
2250 else if (name.compare ("zdata")) |
|
2251 retval = zdata; |
|
2252 else if (name.compare ("keylabel")) |
|
2253 retval = keylabel; |
|
2254 else |
|
2255 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2256 |
6705
|
2257 return retval; |
|
2258 } |
6406
|
2259 |
6705
|
2260 property_list::pval_map_type |
|
2261 surface::surface_properties::factory_defaults (void) |
|
2262 { |
|
2263 property_list::pval_map_type m; |
6406
|
2264 |
6705
|
2265 m["xdata"] = Matrix (); |
|
2266 m["ydata"] = Matrix (); |
|
2267 m["zdata"] = Matrix (); |
|
2268 m["keylabel"] = ""; |
6406
|
2269 |
6705
|
2270 return m; |
|
2271 } |
6406
|
2272 |
|
2273 std::string surface::surface_properties::go_name ("surface"); |
|
2274 |
|
2275 // --------------------------------------------------------------------- |
|
2276 |
|
2277 octave_value |
|
2278 base_graphics_object::get_default (const property_name& name) const |
|
2279 { |
|
2280 graphics_handle parent = get_parent (); |
|
2281 graphics_object parent_obj = gh_manager::get_object (parent); |
|
2282 |
|
2283 return parent_obj.get_default (type () + name); |
|
2284 } |
|
2285 |
|
2286 octave_value |
|
2287 base_graphics_object::get_factory_default (const property_name& name) const |
|
2288 { |
|
2289 graphics_object parent_obj = gh_manager::get_object (0); |
|
2290 |
|
2291 return parent_obj.get_factory_default (type () + name); |
|
2292 } |
|
2293 |
|
2294 gh_manager::gh_manager (void) |
|
2295 : handle_map (), handle_free_list (), next_handle (-1) |
|
2296 { |
|
2297 handle_map[0] = graphics_object (new root_figure ()); |
|
2298 } |
|
2299 |
|
2300 graphics_handle |
|
2301 gh_manager::do_make_graphics_handle (const std::string& go_name, |
|
2302 const graphics_handle& p) |
|
2303 { |
|
2304 graphics_handle h = get_handle (go_name); |
|
2305 |
|
2306 base_graphics_object *go = 0; |
|
2307 |
|
2308 if (go_name == "figure") |
|
2309 go = new figure (h, p); |
|
2310 else if (go_name == "axes") |
|
2311 go = new axes (h, p); |
|
2312 else if (go_name == "line") |
|
2313 go = new line (h, p); |
|
2314 else if (go_name == "text") |
|
2315 go = new text (h, p); |
|
2316 else if (go_name == "image") |
|
2317 go = new image (h, p); |
6807
|
2318 else if (go_name == "patch") |
|
2319 go = new patch (h, p); |
6406
|
2320 else if (go_name == "surface") |
|
2321 go = new surface (h, p); |
|
2322 if (go) |
|
2323 handle_map[h] = graphics_object (go); |
|
2324 else |
|
2325 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", |
|
2326 go_name.c_str ()); |
|
2327 |
|
2328 return h; |
|
2329 } |
|
2330 |
|
2331 graphics_handle |
|
2332 gh_manager::do_make_figure_handle (double val) |
|
2333 { |
|
2334 graphics_handle h = val; |
|
2335 |
|
2336 handle_map[h] = graphics_object (new figure (h, 0)); |
|
2337 |
|
2338 return h; |
|
2339 } |
|
2340 |
|
2341 void |
|
2342 gh_manager::do_push_figure (const graphics_handle& h) |
|
2343 { |
|
2344 do_pop_figure (h); |
|
2345 |
|
2346 figure_list.push_front (h); |
|
2347 } |
|
2348 |
|
2349 void |
|
2350 gh_manager::do_pop_figure (const graphics_handle& h) |
|
2351 { |
|
2352 for (figure_list_iterator p = figure_list.begin (); |
|
2353 p != figure_list.end (); |
|
2354 p++) |
|
2355 { |
|
2356 if (*p == h) |
|
2357 { |
|
2358 figure_list.erase (p); |
|
2359 break; |
|
2360 } |
|
2361 } |
|
2362 } |
|
2363 |
|
2364 property_list::plist_map_type |
|
2365 root_figure::init_factory_properties (void) |
|
2366 { |
|
2367 property_list::plist_map_type plist_map; |
|
2368 |
|
2369 plist_map["figure"] = figure::figure_properties::factory_defaults (); |
|
2370 plist_map["axes"] = axes::axes_properties::factory_defaults (); |
|
2371 plist_map["line"] = line::line_properties::factory_defaults (); |
|
2372 plist_map["text"] = text::text_properties::factory_defaults (); |
|
2373 plist_map["image"] = image::image_properties::factory_defaults (); |
6807
|
2374 plist_map["patch"] = patch::patch_properties::factory_defaults (); |
6406
|
2375 plist_map["surface"] = surface::surface_properties::factory_defaults (); |
|
2376 |
|
2377 return plist_map; |
|
2378 } |
|
2379 |
|
2380 // --------------------------------------------------------------------- |
|
2381 |
|
2382 DEFUN (ishandle, args, , |
|
2383 "-*- texinfo -*-\n\ |
6678
|
2384 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406
|
2385 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
|
2386 @end deftypefn") |
|
2387 { |
|
2388 octave_value retval; |
|
2389 |
|
2390 if (args.length () == 1) |
|
2391 retval = is_handle (args(0)); |
|
2392 else |
|
2393 print_usage (); |
|
2394 |
|
2395 return retval; |
|
2396 } |
|
2397 |
|
2398 DEFUN (set, args, , |
|
2399 "-*- texinfo -*-\n\ |
6678
|
2400 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ |
6732
|
2401 Set the named property value or vector @var{p} to the value @var{v}\n\ |
|
2402 in the graphics handle @var{h}.\n\ |
6406
|
2403 @end deftypefn") |
|
2404 { |
|
2405 octave_value retval; |
|
2406 |
|
2407 int nargin = args.length (); |
|
2408 |
|
2409 if (nargin > 0) |
|
2410 { |
6732
|
2411 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2412 |
|
2413 if (! error_state) |
6732
|
2414 { |
6733
|
2415 bool request_drawnow = false; |
|
2416 |
6732
|
2417 for (octave_idx_type n = 0; n < hcv.length (); n++) |
|
2418 { |
|
2419 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2420 |
6732
|
2421 if (obj) |
|
2422 { |
|
2423 obj.set (args.splice (0, 1)); |
6406
|
2424 |
6733
|
2425 request_drawnow = true; |
6732
|
2426 } |
|
2427 else |
6733
|
2428 { |
|
2429 error ("set: invalid handle (= %g)", hcv(n)); |
|
2430 break; |
|
2431 } |
6732
|
2432 } |
6733
|
2433 |
|
2434 if (! error_state && request_drawnow) |
|
2435 feval ("__request_drawnow__"); |
6732
|
2436 } |
6406
|
2437 else |
6732
|
2438 error ("set: expecting graphics handle as first argument"); |
6406
|
2439 } |
|
2440 else |
|
2441 print_usage (); |
|
2442 |
|
2443 return retval; |
|
2444 } |
|
2445 |
|
2446 DEFUN (get, args, , |
|
2447 "-*- texinfo -*-\n\ |
6678
|
2448 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406
|
2449 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
|
2450 If @var{p} is omitted, return the complete property list for @var{h}.\n\ |
6732
|
2451 If @var{h} is a vector, return a cell array including the property\n\ |
|
2452 values or lists respectively.\n\ |
6406
|
2453 @end deftypefn") |
|
2454 { |
|
2455 octave_value retval; |
6732
|
2456 octave_value_list vlist; |
6406
|
2457 |
|
2458 int nargin = args.length (); |
|
2459 |
|
2460 if (nargin == 1 || nargin == 2) |
|
2461 { |
6732
|
2462 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2463 |
|
2464 if (! error_state) |
6732
|
2465 { |
6733
|
2466 octave_idx_type len = hcv.length (); |
|
2467 |
|
2468 vlist.resize (len); |
|
2469 |
|
2470 for (octave_idx_type n = 0; n < len; n++) |
6732
|
2471 { |
|
2472 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2473 |
6732
|
2474 if (obj) |
|
2475 { |
|
2476 if (nargin == 1) |
|
2477 vlist(n) = obj.get (); |
|
2478 else |
|
2479 { |
|
2480 property_name property = args(1).string_value (); |
6406
|
2481 |
6732
|
2482 if (! error_state) |
|
2483 vlist(n) = obj.get (property); |
|
2484 else |
6733
|
2485 { |
|
2486 error ("get: expecting property name as second argument"); |
|
2487 break; |
|
2488 } |
6732
|
2489 } |
|
2490 } |
|
2491 else |
6733
|
2492 { |
|
2493 error ("get: invalid handle (= %g)", hcv(n)); |
|
2494 break; |
|
2495 } |
6732
|
2496 } |
|
2497 } |
6406
|
2498 else |
6732
|
2499 error ("get: expecting graphics handle as first argument"); |
6406
|
2500 } |
|
2501 else |
|
2502 print_usage (); |
|
2503 |
6733
|
2504 if (! error_state) |
6732
|
2505 { |
6733
|
2506 octave_idx_type len = vlist.length (); |
|
2507 |
|
2508 if (len > 1) |
|
2509 retval = Cell (vlist); |
|
2510 else if (len == 1) |
|
2511 retval = vlist(0); |
6732
|
2512 } |
|
2513 |
6406
|
2514 return retval; |
|
2515 } |
|
2516 |
|
2517 static octave_value |
|
2518 make_graphics_object (const std::string& go_name, |
6732
|
2519 const octave_value_list& args) |
6406
|
2520 { |
|
2521 octave_value retval; |
|
2522 |
|
2523 double val = args(0).double_value (); |
|
2524 |
|
2525 if (! error_state) |
|
2526 { |
|
2527 graphics_handle parent = gh_manager::lookup (val); |
|
2528 |
|
2529 if (! xisnan (parent)) |
|
2530 { |
|
2531 graphics_handle h |
|
2532 = gh_manager::make_graphics_handle (go_name, parent); |
|
2533 |
|
2534 if (! error_state) |
|
2535 { |
|
2536 adopt (parent, h); |
|
2537 |
|
2538 xset (h, args.splice (0, 1)); |
|
2539 |
|
2540 retval = h; |
|
2541 } |
|
2542 else |
|
2543 error ("__go%s__: unable to create graphics handle", |
|
2544 go_name.c_str ()); |
|
2545 } |
|
2546 else |
|
2547 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2548 } |
|
2549 else |
|
2550 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2551 |
|
2552 return retval; |
|
2553 } |
|
2554 |
|
2555 DEFUN (__go_figure__, args, , |
|
2556 "-*- texinfo -*-\n\ |
|
2557 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ |
|
2558 Create a figure graphics object.\n\ |
|
2559 @end deftypefn") |
|
2560 { |
|
2561 octave_value retval; |
|
2562 |
|
2563 if (args.length () > 0) |
|
2564 { |
|
2565 double val = args(0).double_value (); |
|
2566 |
|
2567 if (! error_state) |
|
2568 { |
|
2569 if (is_figure (val)) |
|
2570 { |
|
2571 graphics_handle h = gh_manager::lookup (val); |
|
2572 |
|
2573 xset (h, args.splice (0, 1)); |
|
2574 |
|
2575 retval = h; |
|
2576 } |
|
2577 else |
|
2578 { |
|
2579 graphics_handle h = octave_NaN; |
|
2580 |
|
2581 if (xisnan (val)) |
|
2582 h = gh_manager::make_graphics_handle ("figure", 0); |
|
2583 else if (val > 0 && D_NINT (val) == val) |
|
2584 h = gh_manager::make_figure_handle (val); |
|
2585 else |
|
2586 error ("__go_figure__: invalid figure number"); |
|
2587 |
|
2588 if (! (error_state || xisnan (h))) |
|
2589 { |
|
2590 adopt (0, h); |
|
2591 |
|
2592 xset (h, args.splice (0, 1)); |
|
2593 |
|
2594 retval = h; |
|
2595 } |
|
2596 else |
|
2597 error ("__go_figure__: failed to create figure handle"); |
|
2598 } |
|
2599 } |
|
2600 else |
|
2601 error ("__go_figure__: expecting figure number to be double value"); |
|
2602 } |
|
2603 else |
|
2604 print_usage (); |
|
2605 |
|
2606 return retval; |
|
2607 } |
|
2608 |
|
2609 #define GO_BODY(TYPE) \ |
|
2610 octave_value retval; \ |
|
2611 \ |
|
2612 if (args.length () > 0) \ |
|
2613 retval = make_graphics_object (#TYPE, args); \ |
|
2614 else \ |
|
2615 print_usage (); \ |
|
2616 \ |
|
2617 return retval |
|
2618 |
|
2619 DEFUN (__go_axes__, args, , |
|
2620 "-*- texinfo -*-\n\ |
|
2621 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ |
|
2622 Create an axes graphics object.\n\ |
|
2623 @end deftypefn") |
|
2624 { |
|
2625 GO_BODY (axes); |
|
2626 } |
|
2627 |
|
2628 DEFUN (__go_line__, args, , |
|
2629 "-*- texinfo -*-\n\ |
|
2630 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ |
|
2631 Create a line graphics object.\n\ |
|
2632 @end deftypefn") |
|
2633 { |
|
2634 GO_BODY (line); |
|
2635 } |
|
2636 |
|
2637 DEFUN (__go_text__, args, , |
|
2638 "-*- texinfo -*-\n\ |
|
2639 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ |
|
2640 Create a text graphics object.\n\ |
|
2641 @end deftypefn") |
|
2642 { |
|
2643 GO_BODY (text); |
|
2644 } |
|
2645 |
|
2646 DEFUN (__go_image__, args, , |
|
2647 "-*- texinfo -*-\n\ |
|
2648 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ |
|
2649 Create an image graphics object.\n\ |
|
2650 @end deftypefn") |
|
2651 { |
|
2652 GO_BODY (image); |
|
2653 } |
|
2654 |
|
2655 DEFUN (__go_surface__, args, , |
|
2656 "-*- texinfo -*-\n\ |
|
2657 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ |
|
2658 Create a surface graphics object.\n\ |
|
2659 @end deftypefn") |
|
2660 { |
|
2661 GO_BODY (surface); |
|
2662 } |
|
2663 |
6807
|
2664 DEFUN (__go_patch__, args, , |
|
2665 "-*- texinfo -*-\n\ |
|
2666 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ |
|
2667 Create a patch graphics object.\n\ |
|
2668 @end deftypefn") |
|
2669 { |
|
2670 GO_BODY (patch); |
|
2671 } |
|
2672 |
6406
|
2673 DEFUN (__go_delete__, args, , |
|
2674 "-*- texinfo -*-\n\ |
|
2675 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ |
|
2676 @end deftypefn") |
|
2677 { |
|
2678 octave_value_list retval; |
|
2679 |
|
2680 if (args.length () == 1) |
|
2681 { |
|
2682 graphics_handle h = octave_NaN; |
|
2683 |
|
2684 double val = args(0).double_value (); |
|
2685 |
|
2686 if (! error_state) |
|
2687 { |
|
2688 h = gh_manager::lookup (val); |
|
2689 |
|
2690 if (! xisnan (h)) |
|
2691 { |
|
2692 graphics_object obj = gh_manager::get_object (h); |
|
2693 |
|
2694 graphics_handle parent_h = obj.get_parent (); |
|
2695 |
|
2696 graphics_object parent_obj = gh_manager::get_object (parent_h); |
|
2697 |
|
2698 parent_obj.remove_child (h); |
|
2699 |
|
2700 gh_manager::free (h); |
|
2701 } |
|
2702 else |
|
2703 error ("delete: invalid graphics object (= %g)", val); |
|
2704 } |
|
2705 else |
|
2706 error ("delete: invalid graphics object"); |
|
2707 } |
|
2708 else |
|
2709 print_usage (); |
|
2710 |
|
2711 return retval; |
|
2712 } |
|
2713 |
|
2714 DEFUN (__go_axes_init__, args, , |
|
2715 "-*- texinfo -*-\n\ |
|
2716 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ |
|
2717 Initialize axes object.\n\ |
|
2718 @end deftypefn") |
|
2719 { |
|
2720 octave_value retval; |
|
2721 |
|
2722 int nargin = args.length (); |
|
2723 |
|
2724 std::string mode = ""; |
|
2725 |
|
2726 if (nargin == 2) |
|
2727 { |
|
2728 mode = args(1).string_value (); |
|
2729 |
|
2730 if (error_state) |
|
2731 return retval; |
|
2732 } |
|
2733 |
|
2734 if (nargin == 1 || nargin == 2) |
|
2735 { |
|
2736 graphics_handle h = octave_NaN; |
|
2737 |
|
2738 double val = args(0).double_value (); |
|
2739 |
|
2740 if (! error_state) |
|
2741 { |
|
2742 h = gh_manager::lookup (val); |
|
2743 |
|
2744 if (! xisnan (h)) |
|
2745 { |
|
2746 graphics_object obj = gh_manager::get_object (h); |
|
2747 |
|
2748 obj.set_defaults (mode); |
|
2749 } |
|
2750 else |
|
2751 error ("__go_axes_init__: invalid graphics object (= %g)", val); |
|
2752 } |
|
2753 else |
|
2754 error ("__go_axes_init__: invalid graphics object"); |
|
2755 } |
|
2756 else |
|
2757 print_usage (); |
|
2758 |
|
2759 return retval; |
|
2760 } |
|
2761 |
|
2762 DEFUN (__go_handles__, , , |
|
2763 "-*- texinfo -*-\n\ |
|
2764 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ |
|
2765 Return current list of function handles.\n\ |
|
2766 @end deftypefn") |
|
2767 { |
6425
|
2768 return octave_value (gh_manager::handle_list ()); |
|
2769 } |
|
2770 |
|
2771 DEFUN (__go_figure_handles__, , , |
|
2772 "-*- texinfo -*-\n\ |
|
2773 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ |
|
2774 Return current list of function handles.\n\ |
|
2775 @end deftypefn") |
|
2776 { |
|
2777 return octave_value (gh_manager::figure_handle_list ()); |
6406
|
2778 } |
|
2779 |
6595
|
2780 octave_value |
|
2781 get_property_from_handle (double handle, const std::string &property, |
|
2782 const std::string &func) |
|
2783 { |
|
2784 graphics_object obj = gh_manager::get_object (handle); |
|
2785 octave_value retval; |
|
2786 |
|
2787 if (obj) |
|
2788 { |
|
2789 property_name p = std::string (property); |
|
2790 retval = obj.get (p); |
|
2791 } |
|
2792 else |
|
2793 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
2794 |
|
2795 return retval; |
|
2796 } |
|
2797 |
|
2798 bool |
|
2799 set_property_in_handle (double handle, const std::string &property, |
|
2800 const octave_value &arg, const std::string &func) |
|
2801 { |
|
2802 graphics_object obj = gh_manager::get_object (handle); |
|
2803 int ret = false; |
|
2804 |
|
2805 if (obj) |
|
2806 { |
|
2807 property_name p = std::string (property); |
|
2808 obj.set (p, arg); |
|
2809 if (!error_state) |
|
2810 ret = true; |
|
2811 } |
|
2812 else |
|
2813 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
2814 |
|
2815 return ret; |
|
2816 } |
|
2817 |
6406
|
2818 /* |
|
2819 ;;; Local Variables: *** |
|
2820 ;;; mode: C++ *** |
|
2821 ;;; End: *** |
|
2822 */ |