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 |
7214
|
762 base_properties::update_axis_limits (const std::string& axis_type) const |
|
763 { |
|
764 graphics_handle h = (type == "axes") ? __myhandle__ : parent; |
|
765 |
|
766 graphics_object obj = gh_manager::get_object (h); |
|
767 |
|
768 if (obj.isa ("axes")) |
|
769 obj.update_axis_limits (axis_type); |
|
770 } |
|
771 |
|
772 void |
6836
|
773 base_properties::delete_children (void) |
|
774 { |
|
775 octave_idx_type n = children.numel (); |
|
776 |
|
777 for (octave_idx_type i = 0; i < n; i++) |
|
778 gh_manager::free (children(i)); |
|
779 } |
|
780 |
|
781 void |
6874
|
782 root_figure::properties::set_currentfigure (const graphics_handle& val) |
|
783 { |
|
784 if (error_state) |
|
785 return; |
|
786 |
7059
|
787 if (xisnan (val.value ()) || is_handle (val)) |
6874
|
788 { |
|
789 currentfigure = val; |
|
790 |
|
791 gh_manager::push_figure (currentfigure); |
|
792 } |
|
793 else |
|
794 gripe_set_invalid ("currentfigure"); |
|
795 } |
|
796 |
|
797 void |
7189
|
798 root_figure::properties::set (const caseless_str& name, |
6844
|
799 const octave_value& val) |
6705
|
800 { |
7176
|
801 if (name.compare ("tag")) |
|
802 set_tag (val); |
|
803 else if (name.compare ("currentfigure")) |
6874
|
804 set_currentfigure (val); |
6705
|
805 else if (name.compare ("children")) |
|
806 children = maybe_set_children (children, val); |
|
807 else if (name.compare ("visible")) |
6874
|
808 set_visible (val); |
6705
|
809 else |
|
810 warning ("set: invalid property `%s'", name.c_str ()); |
|
811 } |
6406
|
812 |
6844
|
813 octave_value root_figure::properties::get (void) const |
6705
|
814 { |
|
815 Octave_map m; |
6406
|
816 |
7176
|
817 m.assign ("tag", tag); |
6705
|
818 m.assign ("type", type); |
6874
|
819 m.assign ("currentfigure", currentfigure.as_octave_value ()); |
6705
|
820 m.assign ("children", children); |
|
821 m.assign ("visible", visible); |
6406
|
822 |
6705
|
823 return m; |
|
824 } |
6406
|
825 |
6705
|
826 octave_value |
7189
|
827 root_figure::properties::get (const caseless_str& name) const |
6705
|
828 { |
|
829 octave_value retval; |
6406
|
830 |
7176
|
831 if (name.compare ("tag")) |
|
832 retval = type; |
|
833 else if (name.compare ("tag")) |
6705
|
834 retval = type; |
|
835 else if (name.compare ("currentfigure")) |
6874
|
836 retval = currentfigure.as_octave_value (); |
6705
|
837 else if (name.compare ("children")) |
|
838 retval = children; |
|
839 else if (name.compare ("visible")) |
|
840 retval = visible; |
|
841 else |
|
842 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
843 |
6705
|
844 return retval; |
|
845 } |
6406
|
846 |
|
847 property_list |
|
848 root_figure::factory_properties = root_figure::init_factory_properties (); |
|
849 |
6844
|
850 std::string root_figure::properties::go_name ("root figure"); |
6406
|
851 |
|
852 // --------------------------------------------------------------------- |
|
853 |
6844
|
854 figure::properties::properties (const graphics_handle& mh, |
|
855 const graphics_handle& p) |
6705
|
856 : base_properties (go_name, mh, p), |
|
857 __plot_stream__ (Matrix ()), |
7189
|
858 __enhanced__ (false), |
6705
|
859 nextplot ("replace"), |
|
860 closerequestfcn (make_fcn_handle ("closereq")), |
|
861 currentaxes (octave_NaN), |
|
862 colormap (), |
|
863 visible ("on"), |
|
864 paperorientation ("portrait") |
|
865 { } |
|
866 |
|
867 void |
6874
|
868 figure::properties::set_currentaxes (const graphics_handle& val) |
|
869 { |
|
870 if (error_state) |
|
871 return; |
|
872 |
7070
|
873 if (xisnan (val.value ()) || is_handle (val)) |
6874
|
874 currentaxes = val; |
|
875 else |
|
876 gripe_set_invalid ("currentaxes"); |
|
877 } |
|
878 |
|
879 void |
|
880 figure::properties::set_visible (const octave_value& val) |
|
881 { |
|
882 std::string s = val.string_value (); |
|
883 |
|
884 if (! error_state) |
|
885 { |
|
886 if (s == "on") |
|
887 xset (0, "currentfigure", __myhandle__.value ()); |
|
888 |
|
889 visible = val; |
|
890 } |
|
891 } |
|
892 |
|
893 void |
7189
|
894 figure::properties::set (const caseless_str& name, const octave_value& val) |
6406
|
895 { |
6705
|
896 bool modified = true; |
6406
|
897 |
7176
|
898 if (name.compare ("tag")) |
|
899 set_tag (val); |
|
900 else if (name.compare ("children")) |
6705
|
901 children = maybe_set_children (children, val); |
|
902 else if (name.compare ("__modified__")) |
|
903 { |
|
904 __modified__ = val.bool_value (); |
|
905 modified = false; |
|
906 } |
|
907 else if (name.compare ("__plot_stream__")) |
6874
|
908 set___plot_stream__ (val); |
7189
|
909 else if (name.compare ("__enhanced__")) |
|
910 set___enhanced__ (val); |
6705
|
911 else if (name.compare ("nextplot")) |
6874
|
912 set_nextplot (val); |
6705
|
913 else if (name.compare ("closerequestfcn")) |
6874
|
914 set_closerequestfcn (val); |
6705
|
915 else if (name.compare ("currentaxes")) |
6874
|
916 set_currentaxes (val); |
6705
|
917 else if (name.compare ("colormap")) |
6874
|
918 set_colormap (val); |
6705
|
919 else if (name.compare ("visible")) |
6874
|
920 set_visible (val); |
6705
|
921 else if (name.compare ("paperorientation")) |
6874
|
922 set_paperorientation (val); |
6705
|
923 else |
6406
|
924 { |
6705
|
925 modified = false; |
|
926 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
927 } |
|
928 |
6705
|
929 if (modified) |
|
930 mark_modified (); |
|
931 } |
|
932 |
|
933 octave_value |
6844
|
934 figure::properties::get (void) const |
6705
|
935 { |
|
936 Octave_map m; |
6406
|
937 |
7176
|
938 m.assign ("tag", tag); |
6705
|
939 m.assign ("type", type); |
6874
|
940 m.assign ("parent", parent.as_octave_value ()); |
6705
|
941 m.assign ("children", children); |
|
942 m.assign ("__modified__", __modified__); |
|
943 m.assign ("__plot_stream__", __plot_stream__); |
7189
|
944 m.assign ("__enhanced__", __enhanced__); |
6705
|
945 m.assign ("nextplot", nextplot); |
|
946 m.assign ("closerequestfcn", closerequestfcn); |
6874
|
947 m.assign ("currentaxes", currentaxes.as_octave_value ()); |
6705
|
948 m.assign ("colormap", colormap); |
|
949 m.assign ("visible", visible); |
|
950 m.assign ("paperorientation", paperorientation); |
|
951 |
|
952 return m; |
|
953 } |
|
954 |
|
955 octave_value |
7189
|
956 figure::properties::get (const caseless_str& name) const |
6705
|
957 { |
|
958 octave_value retval; |
6406
|
959 |
7176
|
960 if (name.compare ("tag")) |
|
961 retval = tag; |
|
962 else if (name.compare ("type")) |
6705
|
963 retval = type; |
|
964 else if (name.compare ("parent")) |
6874
|
965 retval = parent.as_octave_value (); |
6705
|
966 else if (name.compare ("children")) |
|
967 retval = children; |
|
968 else if (name.compare ("__modified__")) |
|
969 retval = __modified__; |
|
970 else if (name.compare ("__plot_stream__")) |
|
971 retval = __plot_stream__; |
7189
|
972 else if (name.compare ("__enhanced__")) |
|
973 retval = __enhanced__; |
6705
|
974 else if (name.compare ("nextplot")) |
|
975 retval = nextplot; |
|
976 else if (name.compare ("closerequestfcn")) |
|
977 retval = closerequestfcn; |
|
978 else if (name.compare ("currentaxes")) |
6874
|
979 retval = currentaxes.as_octave_value (); |
6705
|
980 else if (name.compare ("colormap")) |
|
981 retval = colormap; |
|
982 else if (name.compare ("visible")) |
|
983 retval = visible; |
|
984 else if (name.compare ("paperorientation")) |
|
985 retval = paperorientation; |
|
986 else |
|
987 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
988 |
6705
|
989 return retval; |
|
990 } |
6406
|
991 |
6836
|
992 void |
6844
|
993 figure::properties::close (void) |
6705
|
994 { |
|
995 if (! __plot_stream__.is_empty ()) |
6406
|
996 { |
6705
|
997 octave_value_list args; |
|
998 args(1) = "\nquit;\n"; |
|
999 args(0) = __plot_stream__; |
|
1000 feval ("fputs", args); |
|
1001 args.resize (1); |
|
1002 feval ("fflush", args); |
|
1003 feval ("pclose", args); |
6406
|
1004 } |
|
1005 |
6705
|
1006 gh_manager::pop_figure (__myhandle__); |
6406
|
1007 |
6874
|
1008 graphics_handle cf = gh_manager::current_figure (); |
|
1009 |
|
1010 xset (0, "currentfigure", cf.value ()); |
6705
|
1011 } |
6432
|
1012 |
6836
|
1013 property_list::pval_map_type |
6844
|
1014 figure::properties::factory_defaults (void) |
6705
|
1015 { |
|
1016 property_list::pval_map_type m; |
6406
|
1017 |
6705
|
1018 m["nextplot"] = "replace"; |
|
1019 // m["closerequestfcn"] = make_fcn_handle ("closereq"); |
|
1020 m["colormap"] = colormap_property (); |
|
1021 m["visible"] = "on"; |
|
1022 m["paperorientation"] = "portrait"; |
6406
|
1023 |
6705
|
1024 return m; |
|
1025 } |
6406
|
1026 |
6836
|
1027 octave_value |
7189
|
1028 figure::get_default (const caseless_str& name) const |
6836
|
1029 { |
|
1030 octave_value retval = default_properties.lookup (name); |
|
1031 |
|
1032 if (retval.is_undefined ()) |
|
1033 { |
|
1034 graphics_handle parent = get_parent (); |
|
1035 graphics_object parent_obj = gh_manager::get_object (parent); |
|
1036 |
|
1037 retval = parent_obj.get_default (name); |
|
1038 } |
|
1039 |
|
1040 return retval; |
|
1041 } |
|
1042 |
6844
|
1043 std::string figure::properties::go_name ("figure"); |
6406
|
1044 |
|
1045 // --------------------------------------------------------------------- |
|
1046 |
6962
|
1047 static Matrix |
|
1048 default_colororder (void) |
|
1049 { |
|
1050 Matrix retval (7, 3, 0.0); |
|
1051 |
|
1052 retval(0,2) = 1.0; |
|
1053 |
|
1054 retval(1,1) = 0.5; |
|
1055 |
|
1056 retval(2,0) = 1.0; |
|
1057 |
|
1058 retval(3,1) = 0.75; |
|
1059 retval(3,2) = 0.75; |
|
1060 |
|
1061 retval(4,0) = 0.75; |
|
1062 retval(4,2) = 0.75; |
|
1063 |
|
1064 retval(5,0) = 0.75; |
|
1065 retval(5,1) = 0.75; |
|
1066 |
|
1067 retval(6,0) = 0.25; |
|
1068 retval(6,1) = 0.25; |
|
1069 retval(6,2) = 0.25; |
|
1070 |
|
1071 return retval; |
|
1072 } |
|
1073 |
6844
|
1074 axes::properties::properties (const graphics_handle& mh, |
6705
|
1075 const graphics_handle& p) |
|
1076 : base_properties (go_name, mh, p), |
|
1077 position (Matrix ()), |
|
1078 title (octave_NaN), |
|
1079 box ("on"), |
|
1080 key ("off"), |
|
1081 keybox ("off"), |
|
1082 keypos (1), |
6962
|
1083 colororder (default_colororder ()), |
6705
|
1084 dataaspectratio (Matrix (1, 3, 1.0)), |
|
1085 dataaspectratiomode ("auto"), |
|
1086 xlim (), |
|
1087 ylim (), |
|
1088 zlim (), |
6807
|
1089 clim (), |
6705
|
1090 xlimmode ("auto"), |
|
1091 ylimmode ("auto"), |
|
1092 zlimmode ("auto"), |
6807
|
1093 climmode ("auto"), |
6705
|
1094 xlabel (octave_NaN), |
|
1095 ylabel (octave_NaN), |
|
1096 zlabel (octave_NaN), |
|
1097 xgrid ("off"), |
|
1098 ygrid ("off"), |
|
1099 zgrid ("off"), |
|
1100 xminorgrid ("off"), |
|
1101 yminorgrid ("off"), |
|
1102 zminorgrid ("off"), |
|
1103 xtick (Matrix ()), |
|
1104 ytick (Matrix ()), |
|
1105 ztick (Matrix ()), |
|
1106 xtickmode ("auto"), |
|
1107 ytickmode ("auto"), |
|
1108 ztickmode ("auto"), |
|
1109 xticklabel (""), |
|
1110 yticklabel (""), |
|
1111 zticklabel (""), |
|
1112 xticklabelmode ("auto"), |
|
1113 yticklabelmode ("auto"), |
|
1114 zticklabelmode ("auto"), |
7194
|
1115 xcolor (), |
|
1116 ycolor (), |
|
1117 zcolor (), |
6705
|
1118 xscale ("linear"), |
|
1119 yscale ("linear"), |
|
1120 zscale ("linear"), |
|
1121 xdir ("normal"), |
|
1122 ydir ("normal"), |
|
1123 zdir ("normal"), |
6809
|
1124 xaxislocation ("bottom"), |
|
1125 yaxislocation ("left"), |
6705
|
1126 view (), |
6765
|
1127 visible ("on"), |
6705
|
1128 nextplot ("replace"), |
7189
|
1129 outerposition (), |
|
1130 __colorbar__ (radio_values ("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside")) |
6705
|
1131 { |
|
1132 Matrix tlim (1, 2, 0.0); |
|
1133 tlim(1) = 1; |
|
1134 xlim = tlim; |
|
1135 ylim = tlim; |
|
1136 zlim = tlim; |
6807
|
1137 Matrix cl (1, 2, 0); |
|
1138 cl(1) = 1; |
|
1139 clim = cl; |
6705
|
1140 |
|
1141 Matrix tview (1, 2, 0.0); |
|
1142 tview(1) = 90; |
|
1143 view = tview; |
|
1144 |
|
1145 Matrix touterposition (1, 4, 0.0); |
|
1146 touterposition(2) = 1; |
|
1147 touterposition(3) = 1; |
|
1148 outerposition = touterposition; |
|
1149 } |
|
1150 |
|
1151 void |
6874
|
1152 axes::properties::set_title (const graphics_handle& val) |
|
1153 { |
|
1154 if (! error_state) |
|
1155 { |
|
1156 gh_manager::free (title); |
|
1157 title = val; |
|
1158 } |
|
1159 } |
|
1160 |
|
1161 void |
|
1162 axes::properties::set_title (const octave_value& val) |
|
1163 { |
|
1164 set_title (::reparent (val, "set", "title", __myhandle__, false)); |
|
1165 } |
|
1166 |
|
1167 void |
|
1168 axes::properties::set_xlabel (const graphics_handle& val) |
|
1169 { |
|
1170 if (! error_state) |
|
1171 { |
|
1172 gh_manager::free (xlabel); |
|
1173 xlabel = val; |
|
1174 } |
|
1175 } |
|
1176 |
|
1177 void |
|
1178 axes::properties::set_xlabel (const octave_value& val) |
|
1179 { |
|
1180 set_xlabel (::reparent (val, "set", "xlabel", __myhandle__, false)); |
|
1181 } |
|
1182 |
|
1183 void |
|
1184 axes::properties::set_ylabel (const graphics_handle& val) |
|
1185 { |
|
1186 if (! error_state) |
|
1187 { |
|
1188 gh_manager::free (ylabel); |
|
1189 ylabel = val; |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 void |
|
1194 axes::properties::set_ylabel (const octave_value& val) |
|
1195 { |
|
1196 set_ylabel (::reparent (val, "set", "ylabel", __myhandle__, false)); |
|
1197 } |
|
1198 |
|
1199 void |
|
1200 axes::properties::set_zlabel (const graphics_handle& val) |
|
1201 { |
|
1202 if (! error_state) |
|
1203 { |
|
1204 gh_manager::free (zlabel); |
|
1205 zlabel = val; |
|
1206 } |
|
1207 } |
|
1208 |
|
1209 void |
|
1210 axes::properties::set_zlabel (const octave_value& val) |
|
1211 { |
|
1212 set_zlabel (::reparent (val, "set", "zlabel", __myhandle__, false)); |
|
1213 } |
|
1214 |
|
1215 void |
7189
|
1216 axes::properties::set (const caseless_str& name, const octave_value& val) |
6406
|
1217 { |
6705
|
1218 bool modified = true; |
|
1219 |
7176
|
1220 if (name.compare ("tag")) |
|
1221 set_tag (val); |
|
1222 else if (name.compare ("parent")) |
6705
|
1223 set_parent (val); |
|
1224 else if (name.compare ("children")) |
|
1225 children = maybe_set_children (children, val); |
|
1226 else if (name.compare ("__modified__")) |
|
1227 { |
|
1228 __modified__ = val.bool_value (); |
|
1229 modified = false; |
|
1230 } |
|
1231 else if (name.compare ("position")) |
6874
|
1232 set_position (val); |
6705
|
1233 else if (name.compare ("title")) |
6874
|
1234 set_title (val); |
6705
|
1235 else if (name.compare ("box")) |
6874
|
1236 set_box (val); |
6705
|
1237 else if (name.compare ("key")) |
6874
|
1238 set_key (val); |
6705
|
1239 else if (name.compare ("keybox")) |
6874
|
1240 set_keybox (val); |
6705
|
1241 else if (name.compare ("keypos")) |
6874
|
1242 set_keypos (val); |
6962
|
1243 else if (name.compare ("colororder")) |
|
1244 set_colororder (val); |
6705
|
1245 else if (name.compare ("dataaspectratio")) |
6874
|
1246 set_dataaspectratio (val); |
6705
|
1247 else if (name.compare ("dataaspectratiomode")) |
6874
|
1248 set_dataaspectratiomode (val); |
6705
|
1249 else if (name.compare ("xlim")) |
6874
|
1250 set_xlim (val); |
6705
|
1251 else if (name.compare ("ylim")) |
6874
|
1252 set_ylim (val); |
6705
|
1253 else if (name.compare ("zlim")) |
6874
|
1254 set_zlim (val); |
6807
|
1255 else if (name.compare ("clim")) |
6874
|
1256 set_clim (val); |
6705
|
1257 else if (name.compare ("xlimmode")) |
6874
|
1258 set_xlimmode (val); |
6705
|
1259 else if (name.compare ("ylimmode")) |
6874
|
1260 set_ylimmode (val); |
6705
|
1261 else if (name.compare ("zlimmode")) |
6874
|
1262 set_zlimmode (val); |
6807
|
1263 else if (name.compare ("climmode")) |
6874
|
1264 set_climmode (val); |
6705
|
1265 else if (name.compare ("xlabel")) |
6874
|
1266 set_xlabel (val); |
6705
|
1267 else if (name.compare ("ylabel")) |
6874
|
1268 set_ylabel (val); |
6705
|
1269 else if (name.compare ("zlabel")) |
6874
|
1270 set_zlabel (val); |
6705
|
1271 else if (name.compare ("xgrid")) |
6874
|
1272 set_xgrid (val); |
6705
|
1273 else if (name.compare ("ygrid")) |
6874
|
1274 set_ygrid (val); |
6705
|
1275 else if (name.compare ("zgrid")) |
6874
|
1276 set_zgrid (val); |
6705
|
1277 else if (name.compare ("xminorgrid")) |
6874
|
1278 set_xminorgrid (val); |
6705
|
1279 else if (name.compare ("yminorgrid")) |
6874
|
1280 set_yminorgrid (val); |
6705
|
1281 else if (name.compare ("zminorgrid")) |
6874
|
1282 set_zminorgrid (val); |
6705
|
1283 else if (name.compare ("xtick")) |
6874
|
1284 set_xtick (val); |
6705
|
1285 else if (name.compare ("ytick")) |
7030
|
1286 set_ytick (val); |
6705
|
1287 else if (name.compare ("ztick")) |
6874
|
1288 set_ztick (val); |
6705
|
1289 else if (name.compare ("xtickmode")) |
6874
|
1290 set_xtickmode (val); |
6705
|
1291 else if (name.compare ("ytickmode")) |
6874
|
1292 set_ytickmode (val); |
6705
|
1293 else if (name.compare ("ztickmode")) |
6874
|
1294 set_ztickmode (val); |
6705
|
1295 else if (name.compare ("xticklabel")) |
6874
|
1296 set_xticklabel (val); |
6705
|
1297 else if (name.compare ("yticklabel")) |
6874
|
1298 set_yticklabel (val); |
6705
|
1299 else if (name.compare ("zticklabel")) |
6874
|
1300 set_zticklabel (val); |
6705
|
1301 else if (name.compare ("xticklabelmode")) |
6874
|
1302 set_xticklabelmode (val); |
6705
|
1303 else if (name.compare ("yticklabelmode")) |
6874
|
1304 set_yticklabelmode (val); |
6705
|
1305 else if (name.compare ("zticklabelmode")) |
6874
|
1306 set_zticklabelmode (val); |
7194
|
1307 else if (name.compare ("xcolor")) |
|
1308 set_xcolor (val); |
|
1309 else if (name.compare ("ycolor")) |
|
1310 set_ycolor (val); |
|
1311 else if (name.compare ("zcolor")) |
|
1312 set_zcolor (val); |
6705
|
1313 else if (name.compare ("xscale")) |
6874
|
1314 set_xscale (val); |
6705
|
1315 else if (name.compare ("yscale")) |
6874
|
1316 set_yscale (val); |
6705
|
1317 else if (name.compare ("zscale")) |
6874
|
1318 set_zscale (val); |
6705
|
1319 else if (name.compare ("xdir")) |
6874
|
1320 set_xdir (val); |
6705
|
1321 else if (name.compare ("ydir")) |
6874
|
1322 set_ydir (val); |
6705
|
1323 else if (name.compare ("zdir")) |
6874
|
1324 set_zdir (val); |
6809
|
1325 else if (name.compare ("xaxislocation")) |
6874
|
1326 set_xaxislocation (val); |
6809
|
1327 else if (name.compare ("yaxislocation")) |
6874
|
1328 set_yaxislocation (val); |
6705
|
1329 else if (name.compare ("view")) |
6874
|
1330 set_view (val); |
6765
|
1331 else if (name.compare ("visible")) |
6874
|
1332 set_visible (val); |
6705
|
1333 else if (name.compare ("nextplot")) |
6874
|
1334 set_nextplot (val); |
6705
|
1335 else if (name.compare ("outerposition")) |
6874
|
1336 set_outerposition (val); |
7189
|
1337 else if (name.compare ("__colorbar__")) |
|
1338 set___colorbar__ (val); |
6705
|
1339 else |
|
1340 { |
|
1341 modified = false; |
|
1342 warning ("set: invalid property `%s'", name.c_str ()); |
|
1343 } |
6406
|
1344 |
6705
|
1345 if (modified) |
|
1346 mark_modified (); |
|
1347 } |
|
1348 |
|
1349 void |
6844
|
1350 axes::properties::set_defaults (base_graphics_object& obj, |
6890
|
1351 const std::string& mode) |
6705
|
1352 { |
|
1353 position = Matrix (); |
|
1354 title = octave_NaN; |
|
1355 box = "on"; |
|
1356 key = "off"; |
|
1357 keybox = "off"; |
|
1358 keypos = 1; |
6962
|
1359 colororder = default_colororder (); |
6705
|
1360 dataaspectratio = Matrix (1, 3, 1.0); |
|
1361 dataaspectratiomode = "auto"; |
|
1362 |
|
1363 Matrix tlim (1, 2, 0.0); |
|
1364 tlim(1) = 1; |
|
1365 xlim = tlim; |
|
1366 ylim = tlim; |
|
1367 zlim = tlim; |
6807
|
1368 |
|
1369 Matrix cl (1, 2, 0); |
|
1370 cl(1) = 1; |
|
1371 clim = cl; |
|
1372 |
6705
|
1373 xlimmode = "auto"; |
|
1374 ylimmode = "auto"; |
|
1375 zlimmode = "auto"; |
6807
|
1376 climmode = "auto"; |
6705
|
1377 xlabel = octave_NaN; |
|
1378 ylabel = octave_NaN; |
|
1379 zlabel = octave_NaN; |
|
1380 xgrid = "off"; |
|
1381 ygrid = "off"; |
|
1382 zgrid = "off"; |
|
1383 xminorgrid = "off"; |
|
1384 yminorgrid = "off"; |
|
1385 zminorgrid = "off"; |
|
1386 xtick = Matrix (); |
|
1387 ytick = Matrix (); |
|
1388 ztick = Matrix (); |
|
1389 xtickmode = "auto"; |
|
1390 ytickmode = "auto"; |
|
1391 ztickmode = "auto"; |
|
1392 xticklabel = ""; |
|
1393 yticklabel = ""; |
|
1394 zticklabel = ""; |
|
1395 xticklabelmode = "auto"; |
|
1396 yticklabelmode = "auto"; |
|
1397 zticklabelmode = "auto"; |
7194
|
1398 xcolor = color_property ("black"); |
|
1399 ycolor = color_property ("black"); |
|
1400 zcolor = color_property ("black"); |
6705
|
1401 xscale = "linear"; |
|
1402 yscale = "linear"; |
|
1403 zscale = "linear"; |
|
1404 xdir = "normal"; |
|
1405 ydir = "normal"; |
|
1406 zdir = "normal"; |
6809
|
1407 xaxislocation = "left"; |
|
1408 yaxislocation = "bottom"; |
6705
|
1409 |
|
1410 Matrix tview (1, 2, 0.0); |
|
1411 tview(1) = 90; |
|
1412 view = tview; |
|
1413 |
6765
|
1414 visible = "on"; |
6705
|
1415 nextplot = "replace"; |
|
1416 |
|
1417 // FIXME -- this is not quite right; we should preserve |
|
1418 // "position" and "units". |
|
1419 |
|
1420 if (mode != "replace") |
|
1421 { |
6406
|
1422 Matrix touterposition (1, 4, 0.0); |
|
1423 touterposition(2) = 1; |
|
1424 touterposition(3) = 1; |
|
1425 outerposition = touterposition; |
|
1426 } |
|
1427 |
7189
|
1428 __colorbar__ = radio_property (radio_values ("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside")); |
|
1429 |
6705
|
1430 delete_children (); |
6406
|
1431 |
6705
|
1432 children = Matrix (); |
6432
|
1433 |
6705
|
1434 override_defaults (obj); |
|
1435 } |
|
1436 |
6874
|
1437 graphics_handle |
|
1438 axes::properties::get_title (void) const |
|
1439 { |
7056
|
1440 if (! title.ok ()) |
6874
|
1441 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1442 |
|
1443 return title; |
|
1444 } |
|
1445 |
|
1446 graphics_handle |
|
1447 axes::properties::get_xlabel (void) const |
|
1448 { |
7056
|
1449 if (! xlabel.ok ()) |
6874
|
1450 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1451 |
|
1452 return xlabel; |
|
1453 } |
|
1454 |
|
1455 graphics_handle |
|
1456 axes::properties::get_ylabel (void) const |
|
1457 { |
7056
|
1458 if (! ylabel.ok ()) |
6874
|
1459 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1460 |
|
1461 return ylabel; |
|
1462 } |
|
1463 |
|
1464 graphics_handle |
|
1465 axes::properties::get_zlabel (void) const |
|
1466 { |
7056
|
1467 if (! zlabel.ok ()) |
6874
|
1468 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1469 |
|
1470 return zlabel; |
|
1471 } |
|
1472 |
6705
|
1473 octave_value |
6844
|
1474 axes::properties::get (void) const |
6705
|
1475 { |
|
1476 Octave_map m; |
6406
|
1477 |
7176
|
1478 m.assign ("tag", tag); |
6705
|
1479 m.assign ("type", type); |
6874
|
1480 m.assign ("parent", parent.as_octave_value ()); |
6705
|
1481 m.assign ("children", children); |
|
1482 m.assign ("__modified__", __modified__); |
|
1483 m.assign ("position", position); |
6874
|
1484 m.assign ("title", get_title().as_octave_value ()); |
6705
|
1485 m.assign ("box", box); |
|
1486 m.assign ("key", key); |
|
1487 m.assign ("keybox", keybox); |
|
1488 m.assign ("keypos", keypos); |
6962
|
1489 m.assign ("colororder", colororder); |
6705
|
1490 m.assign ("dataaspectratio", dataaspectratio); |
|
1491 m.assign ("dataaspectratiomode", dataaspectratiomode); |
|
1492 m.assign ("xlim", xlim); |
|
1493 m.assign ("ylim", ylim); |
|
1494 m.assign ("zlim", zlim); |
6807
|
1495 m.assign ("clim", clim); |
6705
|
1496 m.assign ("xlimmode", xlimmode); |
|
1497 m.assign ("ylimmode", ylimmode); |
|
1498 m.assign ("zlimmode", zlimmode); |
6807
|
1499 m.assign ("climmode", climmode); |
6874
|
1500 m.assign ("xlabel", get_xlabel().as_octave_value ()); |
|
1501 m.assign ("ylabel", get_ylabel().as_octave_value ()); |
|
1502 m.assign ("zlabel", get_zlabel().as_octave_value ()); |
6705
|
1503 m.assign ("xgrid", xgrid); |
|
1504 m.assign ("ygrid", ygrid); |
|
1505 m.assign ("zgrid", zgrid); |
|
1506 m.assign ("xminorgrid", xminorgrid); |
|
1507 m.assign ("yminorgrid", yminorgrid); |
|
1508 m.assign ("zminorgrid", zminorgrid); |
|
1509 m.assign ("xtick", xtick); |
|
1510 m.assign ("ytick", ytick); |
|
1511 m.assign ("ztick", ztick); |
|
1512 m.assign ("xtickmode", xtickmode); |
|
1513 m.assign ("ytickmode", ytickmode); |
|
1514 m.assign ("ztickmode", ztickmode); |
|
1515 m.assign ("xticklabel", xticklabel); |
|
1516 m.assign ("yticklabel", yticklabel); |
|
1517 m.assign ("zticklabel", zticklabel); |
|
1518 m.assign ("xticklabelmode", xticklabelmode); |
|
1519 m.assign ("yticklabelmode", yticklabelmode); |
|
1520 m.assign ("zticklabelmode", zticklabelmode); |
7194
|
1521 m.assign ("xcolor", xcolor); |
|
1522 m.assign ("ycolor", ycolor); |
|
1523 m.assign ("zcolor", zcolor); |
6705
|
1524 m.assign ("xscale", xscale); |
|
1525 m.assign ("yscale", yscale); |
|
1526 m.assign ("zscale", zscale); |
|
1527 m.assign ("xdir", xdir); |
|
1528 m.assign ("ydir", ydir); |
|
1529 m.assign ("zdir", zdir); |
6809
|
1530 m.assign ("xaxislocation", xaxislocation); |
|
1531 m.assign ("yaxislocation", yaxislocation); |
6705
|
1532 m.assign ("view", view); |
6765
|
1533 m.assign ("visible", visible); |
6705
|
1534 m.assign ("nextplot", nextplot); |
|
1535 m.assign ("outerposition", outerposition); |
7189
|
1536 m.assign ("__colorbar__", __colorbar__); |
6432
|
1537 |
6705
|
1538 return m; |
|
1539 } |
6406
|
1540 |
6705
|
1541 octave_value |
7189
|
1542 axes::properties::get (const caseless_str& name) const |
6705
|
1543 { |
|
1544 octave_value retval; |
6406
|
1545 |
7176
|
1546 if (name.compare ("tag")) |
|
1547 retval = tag; |
|
1548 else if (name.compare ("type")) |
6705
|
1549 retval = type; |
|
1550 else if (name.compare ("parent")) |
6874
|
1551 retval = parent.value (); |
6705
|
1552 else if (name.compare ("children")) |
|
1553 retval = children; |
|
1554 else if (name.compare ("__modified__")) |
|
1555 retval = __modified__; |
|
1556 else if (name.compare ("position")) |
|
1557 retval = position; |
|
1558 else if (name.compare ("title")) |
6874
|
1559 retval = get_title().as_octave_value (); |
6705
|
1560 else if (name.compare ("box")) |
|
1561 retval = box; |
|
1562 else if (name.compare ("key")) |
|
1563 retval = key; |
|
1564 else if (name.compare ("keybox")) |
|
1565 retval = keybox; |
|
1566 else if (name.compare ("keypos")) |
|
1567 retval = keypos; |
6962
|
1568 else if (name.compare ("colororder")) |
|
1569 retval = colororder; |
6705
|
1570 else if (name.compare ("dataaspectratio")) |
|
1571 retval = dataaspectratio; |
|
1572 else if (name.compare ("dataaspectratiomode")) |
|
1573 retval = dataaspectratiomode; |
|
1574 else if (name.compare ("xlim")) |
|
1575 retval = xlim; |
|
1576 else if (name.compare ("ylim")) |
|
1577 retval = ylim; |
|
1578 else if (name.compare ("zlim")) |
|
1579 retval = zlim; |
6807
|
1580 else if (name.compare ("clim")) |
|
1581 retval = clim; |
6705
|
1582 else if (name.compare ("xlimmode")) |
|
1583 retval = xlimmode; |
|
1584 else if (name.compare ("ylimmode")) |
|
1585 retval = ylimmode; |
|
1586 else if (name.compare ("zlimmode")) |
|
1587 retval = zlimmode; |
6807
|
1588 else if (name.compare ("climmode")) |
|
1589 retval = climmode; |
6705
|
1590 else if (name.compare ("xlabel")) |
6874
|
1591 retval = get_xlabel().as_octave_value (); |
6705
|
1592 else if (name.compare ("ylabel")) |
6874
|
1593 retval = get_ylabel().as_octave_value (); |
6705
|
1594 else if (name.compare ("zlabel")) |
6874
|
1595 retval = get_zlabel().as_octave_value (); |
6705
|
1596 else if (name.compare ("xgrid")) |
|
1597 retval = xgrid; |
|
1598 else if (name.compare ("ygrid")) |
|
1599 retval = ygrid; |
|
1600 else if (name.compare ("zgrid")) |
|
1601 retval = zgrid; |
|
1602 else if (name.compare ("xminorgrid")) |
|
1603 retval = xminorgrid; |
|
1604 else if (name.compare ("yminorgrid")) |
|
1605 retval = yminorgrid; |
|
1606 else if (name.compare ("zminorgrid")) |
|
1607 retval = zminorgrid; |
|
1608 else if (name.compare ("xtick")) |
|
1609 retval = xtick; |
|
1610 else if (name.compare ("ytick")) |
|
1611 retval = ytick; |
|
1612 else if (name.compare ("ztick")) |
|
1613 retval = ztick; |
|
1614 else if (name.compare ("xtickmode")) |
|
1615 retval = xtickmode; |
|
1616 else if (name.compare ("ytickmode")) |
|
1617 retval = ytickmode; |
|
1618 else if (name.compare ("ztickmode")) |
|
1619 retval = ztickmode; |
|
1620 else if (name.compare ("xticklabel")) |
|
1621 retval = xticklabel; |
|
1622 else if (name.compare ("yticklabel")) |
|
1623 retval = yticklabel; |
|
1624 else if (name.compare ("zticklabel")) |
|
1625 retval = zticklabel; |
|
1626 else if (name.compare ("xticklabelmode")) |
|
1627 retval = xticklabelmode; |
|
1628 else if (name.compare ("yticklabelmode")) |
|
1629 retval = yticklabelmode; |
|
1630 else if (name.compare ("zticklabelmode")) |
|
1631 retval = zticklabelmode; |
7194
|
1632 else if (name.compare ("xcolor")) |
|
1633 retval = xcolor; |
|
1634 else if (name.compare ("ycolor")) |
|
1635 retval = ycolor; |
|
1636 else if (name.compare ("zcolor")) |
|
1637 retval = zcolor; |
6705
|
1638 else if (name.compare ("xscale")) |
|
1639 retval = xscale; |
|
1640 else if (name.compare ("yscale")) |
|
1641 retval = yscale; |
|
1642 else if (name.compare ("zscale")) |
|
1643 retval = zscale; |
|
1644 else if (name.compare ("xdir")) |
|
1645 retval = xdir; |
|
1646 else if (name.compare ("ydir")) |
|
1647 retval = ydir; |
|
1648 else if (name.compare ("zdir")) |
|
1649 retval = zdir; |
6809
|
1650 else if (name.compare ("xaxislocation")) |
|
1651 retval = xaxislocation; |
|
1652 else if (name.compare ("yaxislocation")) |
|
1653 retval = yaxislocation; |
6705
|
1654 else if (name.compare ("view")) |
|
1655 retval = view; |
6765
|
1656 else if (name.compare ("visible")) |
|
1657 retval = visible; |
6705
|
1658 else if (name.compare ("nextplot")) |
|
1659 retval = nextplot; |
|
1660 else if (name.compare ("outerposition")) |
|
1661 retval = outerposition; |
7189
|
1662 else if (name.compare ("__colorbar__")) |
|
1663 retval = __colorbar__; |
6705
|
1664 else |
|
1665 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
1666 |
6705
|
1667 return retval; |
|
1668 } |
6406
|
1669 |
6705
|
1670 void |
6844
|
1671 axes::properties::remove_child (const graphics_handle& h) |
6705
|
1672 { |
7056
|
1673 if (title.ok () && h == title) |
6705
|
1674 title = gh_manager::make_graphics_handle ("text", __myhandle__); |
7056
|
1675 else if (xlabel.ok () && h == xlabel) |
6705
|
1676 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
7056
|
1677 else if (ylabel.ok () && h == ylabel) |
6705
|
1678 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
7056
|
1679 else if (zlabel.ok () && h == zlabel) |
6705
|
1680 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__); |
|
1681 else |
|
1682 base_properties::remove_child (h); |
|
1683 } |
6406
|
1684 |
6705
|
1685 void |
6844
|
1686 axes::properties::delete_children (void) |
6705
|
1687 { |
|
1688 base_properties::delete_children (); |
|
1689 |
6874
|
1690 gh_manager::free (title); |
|
1691 gh_manager::free (xlabel); |
|
1692 gh_manager::free (ylabel); |
|
1693 gh_manager::free (zlabel); |
6705
|
1694 } |
6406
|
1695 |
6836
|
1696 property_list::pval_map_type |
6844
|
1697 axes::properties::factory_defaults (void) |
6705
|
1698 { |
|
1699 property_list::pval_map_type m; |
6406
|
1700 |
6705
|
1701 m["position"] = Matrix (); |
|
1702 m["title"] = octave_NaN; |
|
1703 m["box"] = "on"; |
|
1704 m["key"] = "off"; |
|
1705 m["keybox"] = "off"; |
|
1706 m["keypos"] = 1; |
6962
|
1707 m["colororder"] = default_colororder (); |
6705
|
1708 m["dataaspectratio"] = Matrix (1, 3, 1.0); |
|
1709 m["dataaspectratiomode"] = "auto"; |
6406
|
1710 |
6705
|
1711 Matrix tlim (1, 2, 0.0); |
|
1712 tlim(1) = 1; |
6406
|
1713 |
6705
|
1714 m["xlim"] = tlim; |
|
1715 m["ylim"] = tlim; |
|
1716 m["zlim"] = tlim; |
6807
|
1717 |
|
1718 Matrix cl(1, 2, 0); |
|
1719 cl(1) = 1; |
|
1720 |
|
1721 m["clim"] = cl; |
6406
|
1722 |
6705
|
1723 m["xlimmode"] = "auto"; |
|
1724 m["ylimmode"] = "auto"; |
|
1725 m["zlimmode"] = "auto"; |
6807
|
1726 m["climmode"] = "auto"; |
6705
|
1727 m["xlabel"] = octave_NaN; |
|
1728 m["ylabel"] = octave_NaN; |
|
1729 m["zlabel"] = octave_NaN; |
|
1730 m["xgrid"] = "off"; |
|
1731 m["ygrid"] = "off"; |
|
1732 m["zgrid"] = "off"; |
|
1733 m["xminorgrid"] = "off"; |
|
1734 m["yminorgrid"] = "off"; |
|
1735 m["zminorgrid"] = "off"; |
|
1736 m["xtick"] = Matrix (); |
|
1737 m["ytick"] = Matrix (); |
|
1738 m["ztick"] = Matrix (); |
|
1739 m["xtickmode"] = "auto"; |
|
1740 m["ytickmode"] = "auto"; |
|
1741 m["ztickmode"] = "auto"; |
|
1742 m["xticklabel"] = ""; |
|
1743 m["yticklabel"] = ""; |
|
1744 m["zticklabel"] = ""; |
|
1745 m["xticklabelmode"] = "auto"; |
|
1746 m["yticklabelmode"] = "auto"; |
|
1747 m["zticklabelmode"] = "auto"; |
7194
|
1748 m["xcolor"] = color_property ("black"); |
|
1749 m["ycolor"] = color_property ("black"); |
|
1750 m["zcolor"] = color_property ("black"); |
6705
|
1751 m["xscale"] = "linear"; |
|
1752 m["yscale"] = "linear"; |
|
1753 m["zscale"] = "linear"; |
|
1754 m["xdir"] = "normal"; |
|
1755 m["ydir"] = "normal"; |
|
1756 m["zdir"] = "normal"; |
6809
|
1757 m["xaxislocation"] = "bottom"; |
|
1758 m["yaxislocation"] = "left"; |
6406
|
1759 |
6705
|
1760 Matrix tview (1, 2, 0.0); |
|
1761 tview(1) = 90; |
6406
|
1762 |
6705
|
1763 m["view"] = tview; |
6406
|
1764 |
6765
|
1765 m["visible"] = "on"; |
6705
|
1766 m["nextplot"] = "replace"; |
6406
|
1767 |
6705
|
1768 Matrix touterposition (1, 4, 0.0); |
|
1769 touterposition(2) = 1; |
|
1770 touterposition(3) = 1; |
6406
|
1771 |
6705
|
1772 m["outerposition"] = touterposition; |
7189
|
1773 m["__colorbar__"] = radio_property (radio_values ("{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside")); |
6406
|
1774 |
6705
|
1775 return m; |
|
1776 } |
6406
|
1777 |
6836
|
1778 octave_value |
7189
|
1779 axes::get_default (const caseless_str& name) const |
6836
|
1780 { |
|
1781 octave_value retval = default_properties.lookup (name); |
|
1782 |
|
1783 if (retval.is_undefined ()) |
|
1784 { |
|
1785 graphics_handle parent = get_parent (); |
|
1786 graphics_object parent_obj = gh_manager::get_object (parent); |
|
1787 |
|
1788 retval = parent_obj.get_default (name); |
|
1789 } |
|
1790 |
|
1791 return retval; |
|
1792 } |
|
1793 |
7214
|
1794 void |
|
1795 axes::update_axis_limits (const std::string& /* axis_type */) |
|
1796 { |
|
1797 } |
|
1798 |
6844
|
1799 std::string axes::properties::go_name ("axes"); |
6406
|
1800 |
|
1801 // --------------------------------------------------------------------- |
|
1802 |
|
1803 static Matrix |
|
1804 default_data (void) |
|
1805 { |
|
1806 Matrix retval (1, 2); |
|
1807 |
|
1808 retval(0) = 0; |
|
1809 retval(1) = 1; |
|
1810 |
|
1811 return retval; |
|
1812 } |
|
1813 |
6844
|
1814 line::properties::properties (const graphics_handle& mh, |
|
1815 const graphics_handle& p) |
6705
|
1816 : base_properties (go_name, mh, p), |
|
1817 xdata (default_data ()), |
|
1818 ydata (default_data ()), |
|
1819 zdata (Matrix ()), |
|
1820 ldata (Matrix ()), |
|
1821 udata (Matrix ()), |
|
1822 xldata (Matrix ()), |
|
1823 xudata (Matrix ()), |
|
1824 color (), |
|
1825 linestyle ("-"), |
|
1826 linewidth (0.5), |
|
1827 marker ("none"), |
|
1828 markeredgecolor ("auto"), |
|
1829 markerfacecolor ("none"), |
|
1830 markersize (1), |
7189
|
1831 keylabel (""), |
|
1832 interpreter (radio_values ("{tex}|none|latex")) |
6705
|
1833 { } |
|
1834 |
|
1835 void |
7189
|
1836 line::properties::set (const caseless_str& name, const octave_value& val) |
6406
|
1837 { |
6705
|
1838 bool modified = true; |
6432
|
1839 |
7176
|
1840 if (name.compare ("tag")) |
|
1841 set_tag (val); |
|
1842 else if (name.compare ("parent")) |
6705
|
1843 set_parent (val); |
|
1844 else if (name.compare ("children")) |
|
1845 children = maybe_set_children (children, val); |
|
1846 else if (name.compare ("__modified__")) |
|
1847 { |
|
1848 __modified__ = val.bool_value (); |
|
1849 modified = false; |
6406
|
1850 } |
6705
|
1851 else if (name.compare ("xdata")) |
6874
|
1852 set_xdata (val); |
6705
|
1853 else if (name.compare ("ydata")) |
6874
|
1854 set_ydata (val); |
6705
|
1855 else if (name.compare ("zdata")) |
6874
|
1856 set_zdata (val); |
6705
|
1857 else if (name.compare ("ldata")) |
6874
|
1858 set_ldata (val); |
6705
|
1859 else if (name.compare ("udata")) |
6874
|
1860 set_udata (val); |
6705
|
1861 else if (name.compare ("xldata")) |
6874
|
1862 set_xldata (val); |
6705
|
1863 else if (name.compare ("xudata")) |
6874
|
1864 set_xudata (val); |
6705
|
1865 else if (name.compare ("color")) |
6874
|
1866 set_color (val); |
6705
|
1867 else if (name.compare ("linestyle")) |
6874
|
1868 set_linestyle (val); |
6705
|
1869 else if (name.compare ("linewidth")) |
6874
|
1870 set_linewidth (val); |
6705
|
1871 else if (name.compare ("marker")) |
6874
|
1872 set_marker (val); |
6705
|
1873 else if (name.compare ("markeredgecolor")) |
6874
|
1874 set_markeredgecolor (val); |
6705
|
1875 else if (name.compare ("markerfacecolor")) |
6874
|
1876 set_markerfacecolor (val); |
6705
|
1877 else if (name.compare ("markersize")) |
6874
|
1878 set_markersize (val); |
6705
|
1879 else if (name.compare ("keylabel")) |
6874
|
1880 set_keylabel (val); |
7189
|
1881 else if (name.compare ("interpreter")) |
|
1882 set_interpreter (val); |
6705
|
1883 else |
6406
|
1884 { |
6705
|
1885 modified = false; |
|
1886 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1887 } |
|
1888 |
6705
|
1889 if (modified) |
|
1890 mark_modified (); |
|
1891 } |
|
1892 |
|
1893 octave_value |
6844
|
1894 line::properties::get (void) const |
6705
|
1895 { |
|
1896 Octave_map m; |
6406
|
1897 |
7176
|
1898 m.assign ("tag", tag); |
6705
|
1899 m.assign ("type", type); |
6874
|
1900 m.assign ("parent", parent.as_octave_value ()); |
6705
|
1901 m.assign ("children", children); |
|
1902 m.assign ("__modified__", __modified__); |
|
1903 m.assign ("xdata", xdata); |
|
1904 m.assign ("ydata", ydata); |
|
1905 m.assign ("zdata", zdata); |
|
1906 m.assign ("ldata", ldata); |
|
1907 m.assign ("udata", udata); |
|
1908 m.assign ("xldata", xldata); |
|
1909 m.assign ("xudata", xudata); |
|
1910 m.assign ("color", color); |
|
1911 m.assign ("linestyle", linestyle); |
|
1912 m.assign ("linewidth", linewidth); |
|
1913 m.assign ("marker", marker); |
|
1914 m.assign ("markeredgecolor", markeredgecolor); |
7086
|
1915 m.assign ("markerfacecolor", markerfacecolor); |
6705
|
1916 m.assign ("markersize", markersize); |
|
1917 m.assign ("keylabel", keylabel); |
7189
|
1918 m.assign ("interpreter", interpreter); |
6406
|
1919 |
6705
|
1920 return m; |
|
1921 } |
6406
|
1922 |
6705
|
1923 octave_value |
7189
|
1924 line::properties::get (const caseless_str& name) const |
6705
|
1925 { |
|
1926 octave_value retval; |
6406
|
1927 |
7176
|
1928 if (name.compare ("tag")) |
|
1929 retval = tag; |
|
1930 else if (name.compare ("type")) |
6705
|
1931 retval = type; |
|
1932 else if (name.compare ("parent")) |
6874
|
1933 retval = parent.as_octave_value (); |
6705
|
1934 else if (name.compare ("children")) |
|
1935 retval = children; |
|
1936 else if (name.compare ("__modified__")) |
|
1937 retval = __modified__; |
|
1938 else if (name.compare ("xdata")) |
|
1939 retval = xdata; |
|
1940 else if (name.compare ("ydata")) |
|
1941 retval = ydata; |
|
1942 else if (name.compare ("zdata")) |
|
1943 retval = zdata; |
|
1944 else if (name.compare ("ldata")) |
|
1945 retval = ldata; |
|
1946 else if (name.compare ("udata")) |
|
1947 retval = udata; |
|
1948 else if (name.compare ("xldata")) |
|
1949 retval = xldata; |
|
1950 else if (name.compare ("xudata")) |
|
1951 retval = xudata; |
|
1952 else if (name.compare ("color")) |
|
1953 retval = color; |
|
1954 else if (name.compare ("linestyle")) |
|
1955 retval = linestyle; |
|
1956 else if (name.compare ("linewidth")) |
|
1957 retval = linewidth; |
|
1958 else if (name.compare ("marker")) |
|
1959 retval = marker; |
|
1960 else if (name.compare ("markeredgecolor")) |
|
1961 retval = markeredgecolor; |
|
1962 else if (name.compare ("markerfacecolor")) |
|
1963 retval = markerfacecolor; |
|
1964 else if (name.compare ("markersize")) |
|
1965 retval = markersize; |
|
1966 else if (name.compare ("keylabel")) |
|
1967 retval = keylabel; |
7189
|
1968 else if (name.compare ("interpreter")) |
|
1969 retval = interpreter; |
6705
|
1970 else |
|
1971 warning ("get: invalid property `%s'", name.c_str ()); |
6432
|
1972 |
6705
|
1973 return retval; |
|
1974 } |
6406
|
1975 |
6836
|
1976 property_list::pval_map_type |
6844
|
1977 line::properties::factory_defaults (void) |
6705
|
1978 { |
|
1979 property_list::pval_map_type m; |
6406
|
1980 |
6705
|
1981 m["xdata"] = default_data (); |
|
1982 m["ydata"] = default_data (); |
|
1983 m["zdata"] = Matrix (); |
|
1984 m["ldata"] = Matrix (); |
|
1985 m["udata"] = Matrix (); |
|
1986 m["xldata"] = Matrix (); |
|
1987 m["xudata"] = Matrix (); |
|
1988 m["color"] = color_property (); |
|
1989 m["linestyle"] = "-"; |
|
1990 m["linewidth"] = 0.5; |
|
1991 m["marker"] = "none"; |
|
1992 m["markeredgecolor"] = "auto"; |
|
1993 m["markerfacecolor"] = "none"; |
|
1994 m["markersize"] = 1; |
|
1995 m["keylabel"] = ""; |
7213
|
1996 m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); |
6406
|
1997 |
6705
|
1998 return m; |
|
1999 } |
6406
|
2000 |
6844
|
2001 std::string line::properties::go_name ("line"); |
6406
|
2002 |
|
2003 // --------------------------------------------------------------------- |
|
2004 |
6844
|
2005 text::properties::properties (const graphics_handle& mh, |
|
2006 const graphics_handle& p) |
6705
|
2007 : base_properties (go_name, mh, p), |
|
2008 string (""), |
|
2009 units ("data"), |
|
2010 position (Matrix (1, 3, 0.0)), |
6724
|
2011 rotation (0), |
6829
|
2012 horizontalalignment ("left"), |
7162
|
2013 color (Matrix (1, 3, 0.0)), |
|
2014 fontname ("Helvetica"), |
7168
|
2015 fontsize (10), |
|
2016 fontangle (radio_values ("{normal}|italic|oblique")), |
7189
|
2017 fontweight (radio_values ("{normal}|bold|demi|light")), |
|
2018 interpreter (radio_values ("{tex}|none|latex")) |
6705
|
2019 { } |
|
2020 |
|
2021 void |
7189
|
2022 text::properties::set (const caseless_str& name, const octave_value& val) |
6406
|
2023 { |
6705
|
2024 bool modified = true; |
6432
|
2025 |
7176
|
2026 if (name.compare ("tag")) |
|
2027 set_tag (val); |
|
2028 else if (name.compare ("parent")) |
6705
|
2029 set_parent (val); |
|
2030 else if (name.compare ("children")) |
|
2031 children = maybe_set_children (children, val); |
|
2032 else if (name.compare ("__modified__")) |
|
2033 { |
|
2034 __modified__ = val.bool_value (); |
|
2035 modified = false; |
6406
|
2036 } |
6705
|
2037 else if (name.compare ("string")) |
6874
|
2038 set_string (val); |
6705
|
2039 else if (name.compare ("units")) |
6874
|
2040 set_units (val); |
6705
|
2041 else if (name.compare ("position")) |
6874
|
2042 set_position (val); |
6724
|
2043 else if (name.compare ("rotation")) |
6874
|
2044 set_rotation (val); |
6705
|
2045 else if (name.compare ("horizontalalignment")) |
6874
|
2046 set_horizontalalignment (val); |
6829
|
2047 else if (name.compare ("color")) |
6874
|
2048 set_color (val); |
7162
|
2049 else if (name.compare ("fontname")) |
|
2050 set_fontname (val); |
|
2051 else if (name.compare ("fontsize")) |
|
2052 set_fontsize (val); |
7168
|
2053 else if (name.compare ("fontangle")) |
|
2054 set_fontangle (val); |
|
2055 else if (name.compare ("fontweight")) |
|
2056 set_fontweight (val); |
7189
|
2057 else if (name.compare ("interpreter")) |
|
2058 set_interpreter (val); |
6705
|
2059 else |
6406
|
2060 { |
6705
|
2061 modified = false; |
|
2062 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2063 } |
|
2064 |
6705
|
2065 if (modified) |
|
2066 mark_modified (); |
|
2067 } |
6406
|
2068 |
6705
|
2069 octave_value |
6844
|
2070 text::properties::get (void) const |
6705
|
2071 { |
|
2072 Octave_map m; |
6406
|
2073 |
7176
|
2074 m.assign ("tag", tag); |
6705
|
2075 m.assign ("type", type); |
6874
|
2076 m.assign ("parent", parent.as_octave_value ()); |
6705
|
2077 m.assign ("children", children); |
|
2078 m.assign ("__modified__", __modified__); |
|
2079 m.assign ("string", string); |
|
2080 m.assign ("units", units); |
|
2081 m.assign ("position", position); |
6724
|
2082 m.assign ("rotation", rotation); |
6705
|
2083 m.assign ("horizontalalignment", horizontalalignment); |
6829
|
2084 m.assign ("color", color); |
7162
|
2085 m.assign ("fontname", fontname); |
|
2086 m.assign ("fontsize", fontsize); |
7168
|
2087 m.assign ("fontangle", fontangle); |
|
2088 m.assign ("fontweight", fontweight); |
7189
|
2089 m.assign ("interpreter", interpreter); |
6406
|
2090 |
6705
|
2091 return m; |
|
2092 } |
6406
|
2093 |
6705
|
2094 octave_value |
7189
|
2095 text::properties::get (const caseless_str& name) const |
6705
|
2096 { |
|
2097 octave_value retval; |
6406
|
2098 |
7176
|
2099 if (name.compare ("tag")) |
|
2100 retval = tag; |
|
2101 else if (name.compare ("type")) |
6705
|
2102 retval = type; |
|
2103 else if (name.compare ("parent")) |
6874
|
2104 retval = parent.as_octave_value (); |
6705
|
2105 else if (name.compare ("children")) |
|
2106 retval = children; |
|
2107 else if (name.compare ("__modified__")) |
|
2108 retval = __modified__; |
|
2109 else if (name.compare ("string")) |
|
2110 retval = string; |
|
2111 else if (name.compare ("units")) |
|
2112 retval = units; |
|
2113 else if (name.compare ("position")) |
|
2114 retval = position; |
6724
|
2115 else if (name.compare ("rotation")) |
|
2116 retval = rotation; |
6705
|
2117 else if (name.compare ("horizontalalignment")) |
|
2118 retval = horizontalalignment; |
6829
|
2119 else if (name.compare ("color")) |
|
2120 retval = color; |
7162
|
2121 else if (name.compare ("fontname")) |
|
2122 retval = fontname; |
|
2123 else if (name.compare ("fontsize")) |
|
2124 retval = fontsize; |
7168
|
2125 else if (name.compare ("fontangle")) |
|
2126 retval = fontangle; |
|
2127 else if (name.compare ("fontweight")) |
|
2128 retval = fontweight; |
7189
|
2129 else if (name.compare ("interpreter")) |
|
2130 retval = interpreter; |
6705
|
2131 else |
|
2132 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2133 |
6705
|
2134 return retval; |
|
2135 } |
6406
|
2136 |
6705
|
2137 property_list::pval_map_type |
6844
|
2138 text::properties::factory_defaults (void) |
6705
|
2139 { |
|
2140 property_list::pval_map_type m; |
6406
|
2141 |
6705
|
2142 m["string"] = ""; |
|
2143 m["units"] = "data"; |
|
2144 m["position"] = Matrix (1, 3, 0.0); |
6724
|
2145 m["rotation"] = 0; |
6705
|
2146 m["horizontalalignment"] = "left"; |
6829
|
2147 m["color"] = Matrix (1, 3, 1.0); |
7162
|
2148 m["fontname"] = "Helvetica"; |
|
2149 m["fontsize"] = 10; |
7213
|
2150 m["fontangle"] = radio_property (radio_values ("{normal}|italic|oblique")); |
|
2151 m["fontweight"] = radio_property (radio_values ("{normal}|bold|demi|light")); |
|
2152 m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); |
6406
|
2153 |
6705
|
2154 return m; |
|
2155 } |
6406
|
2156 |
6844
|
2157 std::string text::properties::go_name ("text"); |
6406
|
2158 |
|
2159 // --------------------------------------------------------------------- |
|
2160 |
6844
|
2161 image::properties::properties (const graphics_handle& mh, |
|
2162 const graphics_handle& p) |
6705
|
2163 : base_properties (go_name, mh, p), |
|
2164 xdata (Matrix ()), |
7213
|
2165 ydata (Matrix ()), |
|
2166 cdata (Matrix ()) |
6705
|
2167 { } |
|
2168 |
|
2169 void |
7189
|
2170 image::properties::set (const caseless_str& name, |
6844
|
2171 const octave_value& val) |
6406
|
2172 { |
6705
|
2173 bool modified = true; |
6432
|
2174 |
7176
|
2175 if (name.compare ("tag")) |
|
2176 set_tag (val); |
|
2177 else if (name.compare ("parent")) |
6705
|
2178 set_parent (val); |
|
2179 else if (name.compare ("children")) |
|
2180 children = maybe_set_children (children, val); |
|
2181 else if (name.compare ("__modified__")) |
|
2182 { |
|
2183 __modified__ = val.bool_value (); |
|
2184 modified = false; |
6406
|
2185 } |
6705
|
2186 else if (name.compare ("xdata")) |
6874
|
2187 set_xdata (val); |
6705
|
2188 else if (name.compare ("ydata")) |
6874
|
2189 set_ydata (val); |
7213
|
2190 else if (name.compare ("cdata")) |
|
2191 set_cdata (val); |
6705
|
2192 else |
6406
|
2193 { |
6705
|
2194 modified = false; |
|
2195 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2196 } |
|
2197 |
6705
|
2198 if (modified) |
|
2199 mark_modified (); |
|
2200 } |
6406
|
2201 |
6705
|
2202 octave_value |
6844
|
2203 image::properties::get (void) const |
6705
|
2204 { |
|
2205 Octave_map m; |
6406
|
2206 |
7176
|
2207 m.assign ("tag", tag); |
6705
|
2208 m.assign ("type", type); |
6874
|
2209 m.assign ("parent", parent.as_octave_value ()); |
6705
|
2210 m.assign ("children", children); |
|
2211 m.assign ("__modified__", __modified__); |
|
2212 m.assign ("xdata", xdata); |
|
2213 m.assign ("ydata", ydata); |
7213
|
2214 m.assign ("cdata", cdata); |
6406
|
2215 |
6705
|
2216 return m; |
|
2217 } |
6406
|
2218 |
6705
|
2219 octave_value |
7189
|
2220 image::properties::get (const caseless_str& name) const |
6705
|
2221 { |
|
2222 octave_value retval; |
6406
|
2223 |
7176
|
2224 if (name.compare ("tag")) |
|
2225 retval = tag; |
|
2226 else if (name.compare ("type")) |
6705
|
2227 retval = type; |
|
2228 else if (name.compare ("parent")) |
6874
|
2229 retval = parent.as_octave_value (); |
6705
|
2230 else if (name.compare ("children")) |
|
2231 retval = children; |
|
2232 else if (name.compare ("__modified__")) |
|
2233 retval = __modified__; |
|
2234 else if (name.compare ("xdata")) |
|
2235 retval = xdata; |
|
2236 else if (name.compare ("ydata")) |
|
2237 retval = ydata; |
7213
|
2238 else if (name.compare ("cdata")) |
|
2239 retval = cdata; |
6705
|
2240 else |
|
2241 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2242 |
6705
|
2243 return retval; |
|
2244 } |
6406
|
2245 |
6836
|
2246 property_list::pval_map_type |
6844
|
2247 image::properties::factory_defaults (void) |
6705
|
2248 { |
|
2249 property_list::pval_map_type m; |
6406
|
2250 |
6705
|
2251 m["xdata"] = Matrix (); |
|
2252 m["ydata"] = Matrix (); |
7213
|
2253 m["cdata"] = Matrix (); |
6406
|
2254 |
6705
|
2255 return m; |
|
2256 } |
6406
|
2257 |
6844
|
2258 std::string image::properties::go_name ("image"); |
6406
|
2259 |
|
2260 // --------------------------------------------------------------------- |
|
2261 |
6844
|
2262 patch::properties::properties (const graphics_handle& mh, |
|
2263 const graphics_handle& p) |
6807
|
2264 : base_properties (go_name, mh, p), |
|
2265 xdata (Matrix ()), |
|
2266 ydata (Matrix ()), |
|
2267 zdata (Matrix ()), |
7213
|
2268 cdata (Matrix ()), |
7020
|
2269 faces (Matrix ()), |
|
2270 vertices (Matrix ()), |
6898
|
2271 facecolor (radio_values ("{flat}|none|interp")), |
6807
|
2272 facealpha (1.0), |
6898
|
2273 edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")), |
6807
|
2274 linestyle ("-"), |
|
2275 linewidth (0.5), |
|
2276 marker ("none"), |
|
2277 markeredgecolor ("auto"), |
|
2278 markerfacecolor ("none"), |
7148
|
2279 markersize (1), |
7189
|
2280 keylabel (""), |
|
2281 interpreter (radio_values ("{tex}|none|latex")) |
6807
|
2282 { } |
|
2283 |
|
2284 void |
7189
|
2285 patch::properties::set (const caseless_str& name, |
6844
|
2286 const octave_value& val) |
6807
|
2287 { |
|
2288 bool modified = true; |
|
2289 |
7176
|
2290 if (name.compare ("tag")) |
|
2291 set_tag (val); |
|
2292 else if (name.compare ("parent")) |
6807
|
2293 set_parent (val); |
|
2294 else if (name.compare ("children")) |
|
2295 children = maybe_set_children (children, val); |
|
2296 else if (name.compare ("__modified__")) |
|
2297 { |
|
2298 __modified__ = val.bool_value (); |
|
2299 modified = false; |
|
2300 } |
|
2301 else if (name.compare ("xdata")) |
6874
|
2302 set_xdata (val); |
6807
|
2303 else if (name.compare ("ydata")) |
6874
|
2304 set_ydata (val); |
6807
|
2305 else if (name.compare ("zdata")) |
6874
|
2306 set_zdata (val); |
7213
|
2307 else if (name.compare ("cdata")) |
|
2308 set_cdata (val); |
7020
|
2309 else if (name.compare ("faces")) |
|
2310 set_faces (val); |
|
2311 else if (name.compare ("vertices")) |
|
2312 set_vertices (val); |
6807
|
2313 else if (name.compare ("facecolor")) |
6938
|
2314 set_facecolor (val); |
6807
|
2315 else if (name.compare ("facealpha")) |
6874
|
2316 set_facealpha (val); |
6807
|
2317 else if (name.compare ("edgecolor")) |
6874
|
2318 set_edgecolor (val); |
6807
|
2319 else if (name.compare ("linestyle")) |
6874
|
2320 set_linestyle (val); |
6807
|
2321 else if (name.compare ("linewidth")) |
6874
|
2322 set_linewidth (val); |
6807
|
2323 else if (name.compare ("marker")) |
6874
|
2324 set_marker (val); |
6807
|
2325 else if (name.compare ("markeredgecolor")) |
6874
|
2326 set_markeredgecolor (val); |
6807
|
2327 else if (name.compare ("markerfacecolor")) |
6874
|
2328 set_markerfacecolor (val); |
6807
|
2329 else if (name.compare ("markersize")) |
6874
|
2330 set_markersize (val); |
7148
|
2331 else if (name.compare ("keylabel")) |
|
2332 set_keylabel (val); |
7189
|
2333 else if (name.compare ("interpreter")) |
|
2334 set_interpreter (val); |
6807
|
2335 else |
|
2336 { |
|
2337 modified = false; |
|
2338 warning ("set: invalid property `%s'", name.c_str ()); |
|
2339 } |
|
2340 |
|
2341 if (modified) |
|
2342 mark_modified (); |
|
2343 } |
|
2344 |
|
2345 octave_value |
6844
|
2346 patch::properties::get (void) const |
6807
|
2347 { |
|
2348 Octave_map m; |
|
2349 |
7176
|
2350 m.assign ("tag", tag); |
6807
|
2351 m.assign ("type", type); |
6874
|
2352 m.assign ("parent", parent.as_octave_value ()); |
6807
|
2353 m.assign ("children", children); |
|
2354 m.assign ("__modified__", __modified__); |
|
2355 m.assign ("xdata", xdata); |
|
2356 m.assign ("ydata", ydata); |
|
2357 m.assign ("zdata", zdata); |
7213
|
2358 m.assign ("cdata", cdata); |
7020
|
2359 m.assign ("faces", faces); |
|
2360 m.assign ("vertices", vertices); |
6807
|
2361 m.assign ("facecolor", facecolor); |
|
2362 m.assign ("facealpha", facealpha); |
|
2363 m.assign ("edgecolor", edgecolor); |
|
2364 m.assign ("linestyle", linestyle); |
|
2365 m.assign ("linewidth", linewidth); |
|
2366 m.assign ("marker", marker); |
|
2367 m.assign ("markeredgecolor", markeredgecolor); |
|
2368 m.assign ("markerface", markerfacecolor); |
|
2369 m.assign ("markersize", markersize); |
7148
|
2370 m.assign ("keylabel", keylabel); |
7189
|
2371 m.assign ("interpreter", interpreter); |
6807
|
2372 |
|
2373 return m; |
|
2374 } |
|
2375 |
|
2376 octave_value |
7189
|
2377 patch::properties::get (const caseless_str& name) const |
6807
|
2378 { |
|
2379 octave_value retval; |
|
2380 |
7176
|
2381 if (name.compare ("tag")) |
|
2382 retval = tag; |
|
2383 else if (name.compare ("type")) |
6807
|
2384 retval = type; |
|
2385 else if (name.compare ("parent")) |
6874
|
2386 retval = parent.as_octave_value (); |
6807
|
2387 else if (name.compare ("children")) |
|
2388 retval = children; |
|
2389 else if (name.compare ("__modified__")) |
|
2390 retval = __modified__; |
|
2391 else if (name.compare ("xdata")) |
|
2392 retval = xdata; |
|
2393 else if (name.compare ("ydata")) |
|
2394 retval = ydata; |
|
2395 else if (name.compare ("zdata")) |
|
2396 retval = zdata; |
7213
|
2397 else if (name.compare ("cdata")) |
|
2398 retval = cdata; |
7020
|
2399 else if (name.compare ("faces")) |
|
2400 retval = faces; |
|
2401 else if (name.compare ("vertices")) |
|
2402 retval = vertices; |
6807
|
2403 else if (name.compare ("facecolor")) |
|
2404 retval = facecolor; |
|
2405 else if (name.compare ("facealpha")) |
7108
|
2406 retval = facealpha; |
6807
|
2407 else if (name.compare ("egdecolor")) |
|
2408 retval = edgecolor; |
|
2409 else if (name.compare ("linestyle")) |
|
2410 retval = linestyle; |
|
2411 else if (name.compare ("linewidth")) |
|
2412 retval = linewidth; |
|
2413 else if (name.compare ("marker")) |
|
2414 retval = marker; |
|
2415 else if (name.compare ("markeredgecolor")) |
|
2416 retval = markeredgecolor; |
|
2417 else if (name.compare ("markerfacecolor")) |
|
2418 retval = markerfacecolor; |
|
2419 else if (name.compare ("markersize")) |
|
2420 retval = markersize; |
7148
|
2421 else if (name.compare ("keylabel")) |
|
2422 retval = keylabel; |
7189
|
2423 else if (name.compare ("interpreter")) |
|
2424 retval = interpreter; |
6807
|
2425 else |
|
2426 warning ("get: invalid property `%s'", name.c_str ()); |
|
2427 |
|
2428 return retval; |
|
2429 } |
|
2430 |
6836
|
2431 property_list::pval_map_type |
6844
|
2432 patch::properties::factory_defaults (void) |
6807
|
2433 { |
|
2434 property_list::pval_map_type m; |
|
2435 |
|
2436 m["xdata"] = Matrix (); |
|
2437 m["ydata"] = Matrix (); |
|
2438 m["zdata"] = Matrix (); |
7213
|
2439 m["cdata"] = Matrix (); |
7020
|
2440 m["faces"] = Matrix (); |
|
2441 m["vertices"] = Matrix (); |
7108
|
2442 m["facecolor"] = color_property (); |
6807
|
2443 m["facealpha"] = 1.0; |
7108
|
2444 m["edgecolor"] = color_property ("black"); |
6807
|
2445 m["linestyle"] = "-"; |
|
2446 m["linewidth"] = 0.5; |
|
2447 m["marker"] = "none"; |
|
2448 m["markeredgecolor"] = "auto"; |
|
2449 m["markerfacecolor"] = "none"; |
|
2450 m["markersize"] = 1; |
7148
|
2451 m["keylabel"] = ""; |
7213
|
2452 m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); |
6807
|
2453 |
|
2454 return m; |
|
2455 } |
|
2456 |
6844
|
2457 std::string patch::properties::go_name ("patch"); |
6807
|
2458 |
|
2459 // --------------------------------------------------------------------- |
|
2460 |
6844
|
2461 surface::properties::properties (const graphics_handle& mh, |
|
2462 const graphics_handle& p) |
6705
|
2463 : base_properties (go_name, mh, p), |
|
2464 xdata (Matrix ()), |
|
2465 ydata (Matrix ()), |
|
2466 zdata (Matrix ()), |
7108
|
2467 cdata (Matrix ()), |
|
2468 facecolor (radio_values ("{flat}|none|interp")), |
|
2469 facealpha (1.0), |
|
2470 edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")), |
|
2471 linestyle ("-"), |
|
2472 linewidth (0.5), |
|
2473 marker ("none"), |
|
2474 markeredgecolor ("auto"), |
|
2475 markerfacecolor ("none"), |
|
2476 markersize (1), |
7189
|
2477 keylabel (""), |
|
2478 interpreter (radio_values ("{tex}|none|latex")) |
6705
|
2479 { } |
|
2480 |
|
2481 void |
7189
|
2482 surface::properties::set (const caseless_str& name, |
6844
|
2483 const octave_value& val) |
6406
|
2484 { |
6705
|
2485 bool modified = true; |
6432
|
2486 |
7176
|
2487 if (name.compare ("tag")) |
|
2488 set_tag (val); |
|
2489 else if (name.compare ("parent")) |
6705
|
2490 set_parent (val); |
|
2491 else if (name.compare ("children")) |
|
2492 children = maybe_set_children (children, val); |
|
2493 else if (name.compare ("__modified__")) |
|
2494 { |
|
2495 __modified__ = val.bool_value (); |
|
2496 modified = false; |
6406
|
2497 } |
6705
|
2498 else if (name.compare ("xdata")) |
6874
|
2499 set_xdata (val); |
6705
|
2500 else if (name.compare ("ydata")) |
6874
|
2501 set_ydata (val); |
6705
|
2502 else if (name.compare ("zdata")) |
6874
|
2503 set_zdata (val); |
7108
|
2504 else if (name.compare ("cdata")) |
|
2505 set_cdata (val); |
|
2506 else if (name.compare ("facecolor")) |
|
2507 set_facecolor (val); |
|
2508 else if (name.compare ("facealpha")) |
|
2509 set_facealpha (val); |
|
2510 else if (name.compare ("edgecolor")) |
|
2511 set_edgecolor (val); |
|
2512 else if (name.compare ("linestyle")) |
|
2513 set_linestyle (val); |
|
2514 else if (name.compare ("linewidth")) |
|
2515 set_linewidth (val); |
|
2516 else if (name.compare ("marker")) |
|
2517 set_marker (val); |
|
2518 else if (name.compare ("markeredgecolor")) |
|
2519 set_markeredgecolor (val); |
|
2520 else if (name.compare ("markerfacecolor")) |
|
2521 set_markerfacecolor (val); |
|
2522 else if (name.compare ("markersize")) |
|
2523 set_markersize (val); |
6705
|
2524 else if (name.compare ("keylabel")) |
6874
|
2525 set_keylabel (val); |
7189
|
2526 else if (name.compare ("interpreter")) |
|
2527 set_interpreter (val); |
6705
|
2528 else |
6406
|
2529 { |
6705
|
2530 modified = false; |
|
2531 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2532 } |
|
2533 |
6705
|
2534 if (modified) |
|
2535 mark_modified (); |
|
2536 } |
6406
|
2537 |
6705
|
2538 octave_value |
6844
|
2539 surface::properties::get (void) const |
6705
|
2540 { |
|
2541 Octave_map m; |
6406
|
2542 |
7176
|
2543 m.assign ("tag", tag); |
6705
|
2544 m.assign ("type", type); |
6874
|
2545 m.assign ("parent", parent.as_octave_value ()); |
6705
|
2546 m.assign ("children", children); |
|
2547 m.assign ("__modified__", __modified__); |
|
2548 m.assign ("xdata", xdata); |
|
2549 m.assign ("ydata", ydata); |
|
2550 m.assign ("zdata", zdata); |
7108
|
2551 m.assign ("cdata", cdata); |
|
2552 m.assign ("facecolor", facecolor); |
|
2553 m.assign ("facealpha", facealpha); |
|
2554 m.assign ("edgecolor", edgecolor); |
|
2555 m.assign ("linestyle", linestyle); |
|
2556 m.assign ("linewidth", linewidth); |
|
2557 m.assign ("marker", marker); |
|
2558 m.assign ("markeredgecolor", markeredgecolor); |
|
2559 m.assign ("markerface", markerfacecolor); |
|
2560 m.assign ("markersize", markersize); |
6705
|
2561 m.assign ("keylabel", keylabel); |
7189
|
2562 m.assign ("interpreter", interpreter); |
6406
|
2563 |
6705
|
2564 return m; |
|
2565 } |
6406
|
2566 |
6705
|
2567 octave_value |
7189
|
2568 surface::properties::get (const caseless_str& name) const |
6705
|
2569 { |
|
2570 octave_value retval; |
6406
|
2571 |
7176
|
2572 if (name.compare ("tag")) |
|
2573 retval = tag; |
|
2574 else if (name.compare ("type")) |
6705
|
2575 retval = type; |
|
2576 else if (name.compare ("parent")) |
6874
|
2577 retval = parent.as_octave_value (); |
6705
|
2578 else if (name.compare ("children")) |
|
2579 retval = children; |
|
2580 else if (name.compare ("__modified__")) |
|
2581 retval = __modified__; |
|
2582 else if (name.compare ("xdata")) |
|
2583 retval = xdata; |
|
2584 else if (name.compare ("ydata")) |
|
2585 retval = ydata; |
|
2586 else if (name.compare ("zdata")) |
|
2587 retval = zdata; |
7108
|
2588 else if (name.compare ("cdata")) |
|
2589 retval = cdata; |
|
2590 else if (name.compare ("facecolor")) |
|
2591 retval = facecolor; |
|
2592 else if (name.compare ("facealpha")) |
|
2593 retval = facealpha; |
|
2594 else if (name.compare ("edgecolor")) |
|
2595 retval = edgecolor; |
|
2596 else if (name.compare ("linestyle")) |
|
2597 retval = linestyle; |
|
2598 else if (name.compare ("linewidth")) |
|
2599 retval = linewidth; |
|
2600 else if (name.compare ("marker")) |
|
2601 retval = marker; |
|
2602 else if (name.compare ("markeredgecolor")) |
|
2603 retval = markeredgecolor; |
|
2604 else if (name.compare ("markerfacecolor")) |
|
2605 retval = markerfacecolor; |
|
2606 else if (name.compare ("markersize")) |
|
2607 retval = markersize; |
6705
|
2608 else if (name.compare ("keylabel")) |
|
2609 retval = keylabel; |
7189
|
2610 else if (name.compare ("interpreter")) |
|
2611 retval = interpreter; |
6705
|
2612 else |
|
2613 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2614 |
6705
|
2615 return retval; |
|
2616 } |
6406
|
2617 |
6705
|
2618 property_list::pval_map_type |
6844
|
2619 surface::properties::factory_defaults (void) |
6705
|
2620 { |
|
2621 property_list::pval_map_type m; |
6406
|
2622 |
6705
|
2623 m["xdata"] = Matrix (); |
|
2624 m["ydata"] = Matrix (); |
|
2625 m["zdata"] = Matrix (); |
7108
|
2626 m["cdata"] = Matrix (); |
|
2627 m["facecolor"] = color_property (); |
|
2628 m["facealpha"] = 1.0; |
|
2629 m["edgecolor"] = color_property ("black"); |
|
2630 m["linestyle"] = "-"; |
|
2631 m["linewidth"] = 0.5; |
|
2632 m["marker"] = "none"; |
|
2633 m["markeredgecolor"] = "auto"; |
|
2634 m["markerfacecolor"] = "none"; |
|
2635 m["markersize"] = 1; |
6705
|
2636 m["keylabel"] = ""; |
7213
|
2637 m["interpreter"] = radio_property (radio_values ("{tex}|none|latex")); |
6406
|
2638 |
6705
|
2639 return m; |
|
2640 } |
6406
|
2641 |
6844
|
2642 std::string surface::properties::go_name ("surface"); |
6406
|
2643 |
|
2644 // --------------------------------------------------------------------- |
|
2645 |
|
2646 octave_value |
7189
|
2647 base_graphics_object::get_default (const caseless_str& name) const |
6406
|
2648 { |
|
2649 graphics_handle parent = get_parent (); |
|
2650 graphics_object parent_obj = gh_manager::get_object (parent); |
|
2651 |
|
2652 return parent_obj.get_default (type () + name); |
|
2653 } |
|
2654 |
|
2655 octave_value |
7189
|
2656 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406
|
2657 { |
|
2658 graphics_object parent_obj = gh_manager::get_object (0); |
|
2659 |
|
2660 return parent_obj.get_factory_default (type () + name); |
|
2661 } |
|
2662 |
|
2663 gh_manager::gh_manager (void) |
|
2664 : handle_map (), handle_free_list (), next_handle (-1) |
|
2665 { |
|
2666 handle_map[0] = graphics_object (new root_figure ()); |
|
2667 } |
|
2668 |
|
2669 graphics_handle |
|
2670 gh_manager::do_make_graphics_handle (const std::string& go_name, |
|
2671 const graphics_handle& p) |
|
2672 { |
|
2673 graphics_handle h = get_handle (go_name); |
|
2674 |
|
2675 base_graphics_object *go = 0; |
|
2676 |
|
2677 if (go_name == "figure") |
|
2678 go = new figure (h, p); |
|
2679 else if (go_name == "axes") |
|
2680 go = new axes (h, p); |
|
2681 else if (go_name == "line") |
|
2682 go = new line (h, p); |
|
2683 else if (go_name == "text") |
|
2684 go = new text (h, p); |
|
2685 else if (go_name == "image") |
|
2686 go = new image (h, p); |
6807
|
2687 else if (go_name == "patch") |
|
2688 go = new patch (h, p); |
6406
|
2689 else if (go_name == "surface") |
|
2690 go = new surface (h, p); |
|
2691 if (go) |
|
2692 handle_map[h] = graphics_object (go); |
|
2693 else |
|
2694 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", |
|
2695 go_name.c_str ()); |
|
2696 |
|
2697 return h; |
|
2698 } |
|
2699 |
|
2700 graphics_handle |
|
2701 gh_manager::do_make_figure_handle (double val) |
|
2702 { |
|
2703 graphics_handle h = val; |
|
2704 |
|
2705 handle_map[h] = graphics_object (new figure (h, 0)); |
|
2706 |
|
2707 return h; |
|
2708 } |
|
2709 |
|
2710 void |
|
2711 gh_manager::do_push_figure (const graphics_handle& h) |
|
2712 { |
|
2713 do_pop_figure (h); |
|
2714 |
|
2715 figure_list.push_front (h); |
|
2716 } |
|
2717 |
|
2718 void |
|
2719 gh_manager::do_pop_figure (const graphics_handle& h) |
|
2720 { |
|
2721 for (figure_list_iterator p = figure_list.begin (); |
|
2722 p != figure_list.end (); |
|
2723 p++) |
|
2724 { |
|
2725 if (*p == h) |
|
2726 { |
|
2727 figure_list.erase (p); |
|
2728 break; |
|
2729 } |
|
2730 } |
|
2731 } |
|
2732 |
|
2733 property_list::plist_map_type |
|
2734 root_figure::init_factory_properties (void) |
|
2735 { |
|
2736 property_list::plist_map_type plist_map; |
|
2737 |
6844
|
2738 plist_map["figure"] = figure::properties::factory_defaults (); |
|
2739 plist_map["axes"] = axes::properties::factory_defaults (); |
|
2740 plist_map["line"] = line::properties::factory_defaults (); |
|
2741 plist_map["text"] = text::properties::factory_defaults (); |
|
2742 plist_map["image"] = image::properties::factory_defaults (); |
|
2743 plist_map["patch"] = patch::properties::factory_defaults (); |
|
2744 plist_map["surface"] = surface::properties::factory_defaults (); |
6406
|
2745 |
|
2746 return plist_map; |
|
2747 } |
|
2748 |
|
2749 // --------------------------------------------------------------------- |
|
2750 |
|
2751 DEFUN (ishandle, args, , |
|
2752 "-*- texinfo -*-\n\ |
6678
|
2753 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406
|
2754 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
|
2755 @end deftypefn") |
|
2756 { |
|
2757 octave_value retval; |
|
2758 |
|
2759 if (args.length () == 1) |
|
2760 retval = is_handle (args(0)); |
|
2761 else |
|
2762 print_usage (); |
|
2763 |
|
2764 return retval; |
|
2765 } |
|
2766 |
|
2767 DEFUN (set, args, , |
|
2768 "-*- texinfo -*-\n\ |
6678
|
2769 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ |
6732
|
2770 Set the named property value or vector @var{p} to the value @var{v}\n\ |
6894
|
2771 for the graphics handle @var{h}.\n\ |
6406
|
2772 @end deftypefn") |
|
2773 { |
|
2774 octave_value retval; |
|
2775 |
|
2776 int nargin = args.length (); |
|
2777 |
|
2778 if (nargin > 0) |
|
2779 { |
6732
|
2780 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2781 |
|
2782 if (! error_state) |
6732
|
2783 { |
6733
|
2784 bool request_drawnow = false; |
|
2785 |
6732
|
2786 for (octave_idx_type n = 0; n < hcv.length (); n++) |
|
2787 { |
|
2788 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2789 |
6732
|
2790 if (obj) |
|
2791 { |
|
2792 obj.set (args.splice (0, 1)); |
6406
|
2793 |
6733
|
2794 request_drawnow = true; |
6732
|
2795 } |
|
2796 else |
6733
|
2797 { |
|
2798 error ("set: invalid handle (= %g)", hcv(n)); |
|
2799 break; |
|
2800 } |
6732
|
2801 } |
6733
|
2802 |
|
2803 if (! error_state && request_drawnow) |
|
2804 feval ("__request_drawnow__"); |
6732
|
2805 } |
6406
|
2806 else |
6732
|
2807 error ("set: expecting graphics handle as first argument"); |
6406
|
2808 } |
|
2809 else |
|
2810 print_usage (); |
|
2811 |
|
2812 return retval; |
|
2813 } |
|
2814 |
|
2815 DEFUN (get, args, , |
|
2816 "-*- texinfo -*-\n\ |
6678
|
2817 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406
|
2818 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
|
2819 If @var{p} is omitted, return the complete property list for @var{h}.\n\ |
6732
|
2820 If @var{h} is a vector, return a cell array including the property\n\ |
|
2821 values or lists respectively.\n\ |
6406
|
2822 @end deftypefn") |
|
2823 { |
|
2824 octave_value retval; |
6732
|
2825 octave_value_list vlist; |
6406
|
2826 |
|
2827 int nargin = args.length (); |
|
2828 |
|
2829 if (nargin == 1 || nargin == 2) |
|
2830 { |
6732
|
2831 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2832 |
|
2833 if (! error_state) |
6732
|
2834 { |
6733
|
2835 octave_idx_type len = hcv.length (); |
|
2836 |
|
2837 vlist.resize (len); |
|
2838 |
|
2839 for (octave_idx_type n = 0; n < len; n++) |
6732
|
2840 { |
|
2841 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2842 |
6732
|
2843 if (obj) |
|
2844 { |
|
2845 if (nargin == 1) |
|
2846 vlist(n) = obj.get (); |
|
2847 else |
|
2848 { |
7189
|
2849 caseless_str property = args(1).string_value (); |
6406
|
2850 |
6732
|
2851 if (! error_state) |
|
2852 vlist(n) = obj.get (property); |
|
2853 else |
6733
|
2854 { |
|
2855 error ("get: expecting property name as second argument"); |
|
2856 break; |
|
2857 } |
6732
|
2858 } |
|
2859 } |
|
2860 else |
6733
|
2861 { |
|
2862 error ("get: invalid handle (= %g)", hcv(n)); |
|
2863 break; |
|
2864 } |
6732
|
2865 } |
|
2866 } |
6406
|
2867 else |
6732
|
2868 error ("get: expecting graphics handle as first argument"); |
6406
|
2869 } |
|
2870 else |
|
2871 print_usage (); |
|
2872 |
6733
|
2873 if (! error_state) |
6732
|
2874 { |
6733
|
2875 octave_idx_type len = vlist.length (); |
|
2876 |
|
2877 if (len > 1) |
|
2878 retval = Cell (vlist); |
|
2879 else if (len == 1) |
|
2880 retval = vlist(0); |
6732
|
2881 } |
|
2882 |
6406
|
2883 return retval; |
|
2884 } |
|
2885 |
|
2886 static octave_value |
|
2887 make_graphics_object (const std::string& go_name, |
6874
|
2888 const octave_value_list& args) |
6406
|
2889 { |
|
2890 octave_value retval; |
|
2891 |
|
2892 double val = args(0).double_value (); |
|
2893 |
|
2894 if (! error_state) |
|
2895 { |
|
2896 graphics_handle parent = gh_manager::lookup (val); |
|
2897 |
7056
|
2898 if (parent.ok ()) |
6406
|
2899 { |
|
2900 graphics_handle h |
|
2901 = gh_manager::make_graphics_handle (go_name, parent); |
|
2902 |
|
2903 if (! error_state) |
|
2904 { |
|
2905 adopt (parent, h); |
|
2906 |
|
2907 xset (h, args.splice (0, 1)); |
|
2908 |
6874
|
2909 retval = h.value (); |
6406
|
2910 } |
|
2911 else |
|
2912 error ("__go%s__: unable to create graphics handle", |
|
2913 go_name.c_str ()); |
|
2914 } |
|
2915 else |
|
2916 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2917 } |
|
2918 else |
|
2919 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2920 |
|
2921 return retval; |
|
2922 } |
|
2923 |
|
2924 DEFUN (__go_figure__, args, , |
|
2925 "-*- texinfo -*-\n\ |
|
2926 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ |
6945
|
2927 Undocumented internal function.\n\ |
6406
|
2928 @end deftypefn") |
|
2929 { |
|
2930 octave_value retval; |
|
2931 |
|
2932 if (args.length () > 0) |
|
2933 { |
|
2934 double val = args(0).double_value (); |
|
2935 |
|
2936 if (! error_state) |
|
2937 { |
|
2938 if (is_figure (val)) |
|
2939 { |
|
2940 graphics_handle h = gh_manager::lookup (val); |
|
2941 |
|
2942 xset (h, args.splice (0, 1)); |
|
2943 |
6874
|
2944 retval = h.value (); |
6406
|
2945 } |
|
2946 else |
|
2947 { |
|
2948 graphics_handle h = octave_NaN; |
|
2949 |
|
2950 if (xisnan (val)) |
|
2951 h = gh_manager::make_graphics_handle ("figure", 0); |
|
2952 else if (val > 0 && D_NINT (val) == val) |
|
2953 h = gh_manager::make_figure_handle (val); |
|
2954 else |
|
2955 error ("__go_figure__: invalid figure number"); |
|
2956 |
7056
|
2957 if (! error_state && h.ok ()) |
6406
|
2958 { |
|
2959 adopt (0, h); |
|
2960 |
|
2961 xset (h, args.splice (0, 1)); |
|
2962 |
6874
|
2963 retval = h.value (); |
6406
|
2964 } |
|
2965 else |
|
2966 error ("__go_figure__: failed to create figure handle"); |
|
2967 } |
|
2968 } |
|
2969 else |
|
2970 error ("__go_figure__: expecting figure number to be double value"); |
|
2971 } |
|
2972 else |
|
2973 print_usage (); |
|
2974 |
|
2975 return retval; |
|
2976 } |
|
2977 |
|
2978 #define GO_BODY(TYPE) \ |
|
2979 octave_value retval; \ |
|
2980 \ |
|
2981 if (args.length () > 0) \ |
|
2982 retval = make_graphics_object (#TYPE, args); \ |
|
2983 else \ |
|
2984 print_usage (); \ |
|
2985 \ |
|
2986 return retval |
|
2987 |
|
2988 DEFUN (__go_axes__, args, , |
|
2989 "-*- texinfo -*-\n\ |
|
2990 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ |
6945
|
2991 Undocumented internal function.\n\ |
6406
|
2992 @end deftypefn") |
|
2993 { |
|
2994 GO_BODY (axes); |
|
2995 } |
|
2996 |
|
2997 DEFUN (__go_line__, args, , |
|
2998 "-*- texinfo -*-\n\ |
|
2999 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ |
6945
|
3000 Undocumented internal function.\n\ |
6406
|
3001 @end deftypefn") |
|
3002 { |
|
3003 GO_BODY (line); |
|
3004 } |
|
3005 |
|
3006 DEFUN (__go_text__, args, , |
|
3007 "-*- texinfo -*-\n\ |
|
3008 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ |
6945
|
3009 Undocumented internal function.\n\ |
6406
|
3010 @end deftypefn") |
|
3011 { |
|
3012 GO_BODY (text); |
|
3013 } |
|
3014 |
|
3015 DEFUN (__go_image__, args, , |
|
3016 "-*- texinfo -*-\n\ |
|
3017 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ |
6945
|
3018 Undocumented internal function.\n\ |
6406
|
3019 @end deftypefn") |
|
3020 { |
|
3021 GO_BODY (image); |
|
3022 } |
|
3023 |
|
3024 DEFUN (__go_surface__, args, , |
|
3025 "-*- texinfo -*-\n\ |
|
3026 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ |
6945
|
3027 Undocumented internal function.\n\ |
6406
|
3028 @end deftypefn") |
|
3029 { |
|
3030 GO_BODY (surface); |
|
3031 } |
|
3032 |
6807
|
3033 DEFUN (__go_patch__, args, , |
|
3034 "-*- texinfo -*-\n\ |
|
3035 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ |
6945
|
3036 Undocumented internal function.\n\ |
6807
|
3037 @end deftypefn") |
|
3038 { |
|
3039 GO_BODY (patch); |
|
3040 } |
|
3041 |
6406
|
3042 DEFUN (__go_delete__, args, , |
|
3043 "-*- texinfo -*-\n\ |
|
3044 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ |
6945
|
3045 Undocumented internal function.\n\ |
6406
|
3046 @end deftypefn") |
|
3047 { |
|
3048 octave_value_list retval; |
|
3049 |
|
3050 if (args.length () == 1) |
|
3051 { |
|
3052 graphics_handle h = octave_NaN; |
|
3053 |
|
3054 double val = args(0).double_value (); |
|
3055 |
|
3056 if (! error_state) |
|
3057 { |
|
3058 h = gh_manager::lookup (val); |
|
3059 |
7056
|
3060 if (h.ok ()) |
6406
|
3061 { |
|
3062 graphics_object obj = gh_manager::get_object (h); |
|
3063 |
|
3064 graphics_handle parent_h = obj.get_parent (); |
|
3065 |
|
3066 graphics_object parent_obj = gh_manager::get_object (parent_h); |
|
3067 |
|
3068 parent_obj.remove_child (h); |
|
3069 |
|
3070 gh_manager::free (h); |
|
3071 } |
|
3072 else |
|
3073 error ("delete: invalid graphics object (= %g)", val); |
|
3074 } |
|
3075 else |
|
3076 error ("delete: invalid graphics object"); |
|
3077 } |
|
3078 else |
|
3079 print_usage (); |
|
3080 |
|
3081 return retval; |
|
3082 } |
|
3083 |
|
3084 DEFUN (__go_axes_init__, args, , |
|
3085 "-*- texinfo -*-\n\ |
|
3086 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ |
6945
|
3087 Undocumented internal function.\n\ |
6406
|
3088 @end deftypefn") |
|
3089 { |
|
3090 octave_value retval; |
|
3091 |
|
3092 int nargin = args.length (); |
|
3093 |
|
3094 std::string mode = ""; |
|
3095 |
|
3096 if (nargin == 2) |
|
3097 { |
|
3098 mode = args(1).string_value (); |
|
3099 |
|
3100 if (error_state) |
|
3101 return retval; |
|
3102 } |
|
3103 |
|
3104 if (nargin == 1 || nargin == 2) |
|
3105 { |
|
3106 graphics_handle h = octave_NaN; |
|
3107 |
|
3108 double val = args(0).double_value (); |
|
3109 |
|
3110 if (! error_state) |
|
3111 { |
|
3112 h = gh_manager::lookup (val); |
|
3113 |
7056
|
3114 if (h.ok ()) |
6406
|
3115 { |
|
3116 graphics_object obj = gh_manager::get_object (h); |
|
3117 |
|
3118 obj.set_defaults (mode); |
|
3119 } |
|
3120 else |
|
3121 error ("__go_axes_init__: invalid graphics object (= %g)", val); |
|
3122 } |
|
3123 else |
|
3124 error ("__go_axes_init__: invalid graphics object"); |
|
3125 } |
|
3126 else |
|
3127 print_usage (); |
|
3128 |
|
3129 return retval; |
|
3130 } |
|
3131 |
|
3132 DEFUN (__go_handles__, , , |
|
3133 "-*- texinfo -*-\n\ |
|
3134 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ |
6945
|
3135 Undocumented internal function.\n\ |
6406
|
3136 @end deftypefn") |
|
3137 { |
6425
|
3138 return octave_value (gh_manager::handle_list ()); |
|
3139 } |
|
3140 |
|
3141 DEFUN (__go_figure_handles__, , , |
|
3142 "-*- texinfo -*-\n\ |
|
3143 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ |
6945
|
3144 Undocumented internal function.\n\ |
6425
|
3145 @end deftypefn") |
|
3146 { |
|
3147 return octave_value (gh_manager::figure_handle_list ()); |
6406
|
3148 } |
|
3149 |
6595
|
3150 octave_value |
|
3151 get_property_from_handle (double handle, const std::string &property, |
|
3152 const std::string &func) |
|
3153 { |
|
3154 graphics_object obj = gh_manager::get_object (handle); |
|
3155 octave_value retval; |
|
3156 |
|
3157 if (obj) |
|
3158 { |
7189
|
3159 caseless_str p = std::string (property); |
6595
|
3160 retval = obj.get (p); |
|
3161 } |
|
3162 else |
|
3163 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
3164 |
|
3165 return retval; |
|
3166 } |
|
3167 |
|
3168 bool |
|
3169 set_property_in_handle (double handle, const std::string &property, |
|
3170 const octave_value &arg, const std::string &func) |
|
3171 { |
|
3172 graphics_object obj = gh_manager::get_object (handle); |
|
3173 int ret = false; |
|
3174 |
|
3175 if (obj) |
|
3176 { |
7189
|
3177 caseless_str p = std::string (property); |
6595
|
3178 obj.set (p, arg); |
|
3179 if (!error_state) |
|
3180 ret = true; |
|
3181 } |
|
3182 else |
|
3183 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
3184 |
|
3185 return ret; |
|
3186 } |
|
3187 |
6406
|
3188 /* |
|
3189 ;;; Local Variables: *** |
|
3190 ;;; mode: C++ *** |
|
3191 ;;; End: *** |
|
3192 */ |