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