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