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