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