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