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 |
|
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 |
7059
|
765 if (xisnan (val.value ()) || is_handle (val)) |
6874
|
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 |
7070
|
845 if (xisnan (val.value ()) || is_handle (val)) |
6874
|
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); |
7086
|
1828 m.assign ("markerfacecolor", markerfacecolor); |
6705
|
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"), |
7162
|
1920 color (Matrix (1, 3, 0.0)), |
|
1921 fontname ("Helvetica"), |
|
1922 fontsize (10) |
6705
|
1923 { } |
|
1924 |
|
1925 void |
6844
|
1926 text::properties::set (const property_name& name, const octave_value& val) |
6406
|
1927 { |
6705
|
1928 bool modified = true; |
6432
|
1929 |
6705
|
1930 if (name.compare ("parent")) |
|
1931 set_parent (val); |
|
1932 else if (name.compare ("children")) |
|
1933 children = maybe_set_children (children, val); |
|
1934 else if (name.compare ("__modified__")) |
|
1935 { |
|
1936 __modified__ = val.bool_value (); |
|
1937 modified = false; |
6406
|
1938 } |
6705
|
1939 else if (name.compare ("string")) |
6874
|
1940 set_string (val); |
6705
|
1941 else if (name.compare ("units")) |
6874
|
1942 set_units (val); |
6705
|
1943 else if (name.compare ("position")) |
6874
|
1944 set_position (val); |
6724
|
1945 else if (name.compare ("rotation")) |
6874
|
1946 set_rotation (val); |
6705
|
1947 else if (name.compare ("horizontalalignment")) |
6874
|
1948 set_horizontalalignment (val); |
6829
|
1949 else if (name.compare ("color")) |
6874
|
1950 set_color (val); |
7162
|
1951 else if (name.compare ("fontname")) |
|
1952 set_fontname (val); |
|
1953 else if (name.compare ("fontsize")) |
|
1954 set_fontsize (val); |
6705
|
1955 else |
6406
|
1956 { |
6705
|
1957 modified = false; |
|
1958 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
1959 } |
|
1960 |
6705
|
1961 if (modified) |
|
1962 mark_modified (); |
|
1963 } |
6406
|
1964 |
6705
|
1965 octave_value |
6844
|
1966 text::properties::get (void) const |
6705
|
1967 { |
|
1968 Octave_map m; |
6406
|
1969 |
6705
|
1970 m.assign ("type", type); |
6874
|
1971 m.assign ("parent", parent.as_octave_value ()); |
6705
|
1972 m.assign ("children", children); |
|
1973 m.assign ("__modified__", __modified__); |
|
1974 m.assign ("string", string); |
|
1975 m.assign ("units", units); |
|
1976 m.assign ("position", position); |
6724
|
1977 m.assign ("rotation", rotation); |
6705
|
1978 m.assign ("horizontalalignment", horizontalalignment); |
6829
|
1979 m.assign ("color", color); |
7162
|
1980 m.assign ("fontname", fontname); |
|
1981 m.assign ("fontsize", fontsize); |
6406
|
1982 |
6705
|
1983 return m; |
|
1984 } |
6406
|
1985 |
6705
|
1986 octave_value |
6844
|
1987 text::properties::get (const property_name& name) const |
6705
|
1988 { |
|
1989 octave_value retval; |
6406
|
1990 |
6705
|
1991 if (name.compare ("type")) |
|
1992 retval = type; |
|
1993 else if (name.compare ("parent")) |
6874
|
1994 retval = parent.as_octave_value (); |
6705
|
1995 else if (name.compare ("children")) |
|
1996 retval = children; |
|
1997 else if (name.compare ("__modified__")) |
|
1998 retval = __modified__; |
|
1999 else if (name.compare ("string")) |
|
2000 retval = string; |
|
2001 else if (name.compare ("units")) |
|
2002 retval = units; |
|
2003 else if (name.compare ("position")) |
|
2004 retval = position; |
6724
|
2005 else if (name.compare ("rotation")) |
|
2006 retval = rotation; |
6705
|
2007 else if (name.compare ("horizontalalignment")) |
|
2008 retval = horizontalalignment; |
6829
|
2009 else if (name.compare ("color")) |
|
2010 retval = color; |
7162
|
2011 else if (name.compare ("fontname")) |
|
2012 retval = fontname; |
|
2013 else if (name.compare ("fontsize")) |
|
2014 retval = fontsize; |
6705
|
2015 else |
|
2016 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2017 |
6705
|
2018 return retval; |
|
2019 } |
6406
|
2020 |
6705
|
2021 property_list::pval_map_type |
6844
|
2022 text::properties::factory_defaults (void) |
6705
|
2023 { |
|
2024 property_list::pval_map_type m; |
6406
|
2025 |
6705
|
2026 m["string"] = ""; |
|
2027 m["units"] = "data"; |
|
2028 m["position"] = Matrix (1, 3, 0.0); |
6724
|
2029 m["rotation"] = 0; |
6705
|
2030 m["horizontalalignment"] = "left"; |
6829
|
2031 m["color"] = Matrix (1, 3, 1.0); |
7162
|
2032 m["fontname"] = "Helvetica"; |
|
2033 m["fontsize"] = 10; |
6406
|
2034 |
6705
|
2035 return m; |
|
2036 } |
6406
|
2037 |
6844
|
2038 std::string text::properties::go_name ("text"); |
6406
|
2039 |
|
2040 // --------------------------------------------------------------------- |
|
2041 |
6844
|
2042 image::properties::properties (const graphics_handle& mh, |
|
2043 const graphics_handle& p) |
6705
|
2044 : base_properties (go_name, mh, p), |
|
2045 cdata (Matrix ()), |
|
2046 xdata (Matrix ()), |
|
2047 ydata (Matrix ()) |
|
2048 { } |
|
2049 |
|
2050 void |
6844
|
2051 image::properties::set (const property_name& name, |
|
2052 const octave_value& val) |
6406
|
2053 { |
6705
|
2054 bool modified = true; |
6432
|
2055 |
6705
|
2056 if (name.compare ("parent")) |
|
2057 set_parent (val); |
|
2058 else if (name.compare ("children")) |
|
2059 children = maybe_set_children (children, val); |
|
2060 else if (name.compare ("__modified__")) |
|
2061 { |
|
2062 __modified__ = val.bool_value (); |
|
2063 modified = false; |
6406
|
2064 } |
6705
|
2065 else if (name.compare ("cdata")) |
6874
|
2066 set_cdata (val); |
6705
|
2067 else if (name.compare ("xdata")) |
6874
|
2068 set_xdata (val); |
6705
|
2069 else if (name.compare ("ydata")) |
6874
|
2070 set_ydata (val); |
6705
|
2071 else |
6406
|
2072 { |
6705
|
2073 modified = false; |
|
2074 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2075 } |
|
2076 |
6705
|
2077 if (modified) |
|
2078 mark_modified (); |
|
2079 } |
6406
|
2080 |
6705
|
2081 octave_value |
6844
|
2082 image::properties::get (void) const |
6705
|
2083 { |
|
2084 Octave_map m; |
6406
|
2085 |
6705
|
2086 m.assign ("type", type); |
6874
|
2087 m.assign ("parent", parent.as_octave_value ()); |
6705
|
2088 m.assign ("children", children); |
|
2089 m.assign ("__modified__", __modified__); |
|
2090 m.assign ("cdata", cdata); |
|
2091 m.assign ("xdata", xdata); |
|
2092 m.assign ("ydata", ydata); |
6406
|
2093 |
6705
|
2094 return m; |
|
2095 } |
6406
|
2096 |
6705
|
2097 octave_value |
6844
|
2098 image::properties::get (const property_name& name) const |
6705
|
2099 { |
|
2100 octave_value retval; |
6406
|
2101 |
6705
|
2102 if (name.compare ("type")) |
|
2103 retval = type; |
|
2104 else if (name.compare ("parent")) |
6874
|
2105 retval = parent.as_octave_value (); |
6705
|
2106 else if (name.compare ("children")) |
|
2107 retval = children; |
|
2108 else if (name.compare ("__modified__")) |
|
2109 retval = __modified__; |
|
2110 else if (name.compare ("cdata")) |
|
2111 retval = cdata; |
|
2112 else if (name.compare ("xdata")) |
|
2113 retval = xdata; |
|
2114 else if (name.compare ("ydata")) |
|
2115 retval = ydata; |
|
2116 else |
|
2117 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2118 |
6705
|
2119 return retval; |
|
2120 } |
6406
|
2121 |
6836
|
2122 property_list::pval_map_type |
6844
|
2123 image::properties::factory_defaults (void) |
6705
|
2124 { |
|
2125 property_list::pval_map_type m; |
6406
|
2126 |
6705
|
2127 m["cdata"] = Matrix (); |
|
2128 m["xdata"] = Matrix (); |
|
2129 m["ydata"] = Matrix (); |
6406
|
2130 |
6705
|
2131 return m; |
|
2132 } |
6406
|
2133 |
6844
|
2134 std::string image::properties::go_name ("image"); |
6406
|
2135 |
|
2136 // --------------------------------------------------------------------- |
|
2137 |
6844
|
2138 patch::properties::properties (const graphics_handle& mh, |
|
2139 const graphics_handle& p) |
6807
|
2140 : base_properties (go_name, mh, p), |
|
2141 cdata (Matrix ()), |
|
2142 xdata (Matrix ()), |
|
2143 ydata (Matrix ()), |
|
2144 zdata (Matrix ()), |
7020
|
2145 faces (Matrix ()), |
|
2146 vertices (Matrix ()), |
6898
|
2147 facecolor (radio_values ("{flat}|none|interp")), |
6807
|
2148 facealpha (1.0), |
6898
|
2149 edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")), |
6807
|
2150 linestyle ("-"), |
|
2151 linewidth (0.5), |
|
2152 marker ("none"), |
|
2153 markeredgecolor ("auto"), |
|
2154 markerfacecolor ("none"), |
7148
|
2155 markersize (1), |
|
2156 keylabel ("") |
6807
|
2157 { } |
|
2158 |
|
2159 void |
6844
|
2160 patch::properties::set (const property_name& name, |
|
2161 const octave_value& val) |
6807
|
2162 { |
|
2163 bool modified = true; |
|
2164 |
|
2165 if (name.compare ("parent")) |
|
2166 set_parent (val); |
|
2167 else if (name.compare ("children")) |
|
2168 children = maybe_set_children (children, val); |
|
2169 else if (name.compare ("__modified__")) |
|
2170 { |
|
2171 __modified__ = val.bool_value (); |
|
2172 modified = false; |
|
2173 } |
|
2174 else if (name.compare ("cdata")) |
6874
|
2175 set_cdata (val); |
6807
|
2176 else if (name.compare ("xdata")) |
6874
|
2177 set_xdata (val); |
6807
|
2178 else if (name.compare ("ydata")) |
6874
|
2179 set_ydata (val); |
6807
|
2180 else if (name.compare ("zdata")) |
6874
|
2181 set_zdata (val); |
7020
|
2182 else if (name.compare ("faces")) |
|
2183 set_faces (val); |
|
2184 else if (name.compare ("vertices")) |
|
2185 set_vertices (val); |
6807
|
2186 else if (name.compare ("facecolor")) |
6938
|
2187 set_facecolor (val); |
6807
|
2188 else if (name.compare ("facealpha")) |
6874
|
2189 set_facealpha (val); |
6807
|
2190 else if (name.compare ("edgecolor")) |
6874
|
2191 set_edgecolor (val); |
6807
|
2192 else if (name.compare ("linestyle")) |
6874
|
2193 set_linestyle (val); |
6807
|
2194 else if (name.compare ("linewidth")) |
6874
|
2195 set_linewidth (val); |
6807
|
2196 else if (name.compare ("marker")) |
6874
|
2197 set_marker (val); |
6807
|
2198 else if (name.compare ("markeredgecolor")) |
6874
|
2199 set_markeredgecolor (val); |
6807
|
2200 else if (name.compare ("markerfacecolor")) |
6874
|
2201 set_markerfacecolor (val); |
6807
|
2202 else if (name.compare ("markersize")) |
6874
|
2203 set_markersize (val); |
7148
|
2204 else if (name.compare ("keylabel")) |
|
2205 set_keylabel (val); |
6807
|
2206 else |
|
2207 { |
|
2208 modified = false; |
|
2209 warning ("set: invalid property `%s'", name.c_str ()); |
|
2210 } |
|
2211 |
|
2212 if (modified) |
|
2213 mark_modified (); |
|
2214 } |
|
2215 |
|
2216 octave_value |
6844
|
2217 patch::properties::get (void) const |
6807
|
2218 { |
|
2219 Octave_map m; |
|
2220 |
|
2221 m.assign ("type", type); |
6874
|
2222 m.assign ("parent", parent.as_octave_value ()); |
6807
|
2223 m.assign ("children", children); |
|
2224 m.assign ("__modified__", __modified__); |
|
2225 m.assign ("cdata", cdata); |
|
2226 m.assign ("xdata", xdata); |
|
2227 m.assign ("ydata", ydata); |
|
2228 m.assign ("zdata", zdata); |
7020
|
2229 m.assign ("faces", faces); |
|
2230 m.assign ("vertices", vertices); |
6807
|
2231 m.assign ("facecolor", facecolor); |
|
2232 m.assign ("facealpha", facealpha); |
|
2233 m.assign ("edgecolor", edgecolor); |
|
2234 m.assign ("linestyle", linestyle); |
|
2235 m.assign ("linewidth", linewidth); |
|
2236 m.assign ("marker", marker); |
|
2237 m.assign ("markeredgecolor", markeredgecolor); |
|
2238 m.assign ("markerface", markerfacecolor); |
|
2239 m.assign ("markersize", markersize); |
7148
|
2240 m.assign ("keylabel", keylabel); |
6807
|
2241 |
|
2242 return m; |
|
2243 } |
|
2244 |
|
2245 octave_value |
6844
|
2246 patch::properties::get (const property_name& name) const |
6807
|
2247 { |
|
2248 octave_value retval; |
|
2249 |
|
2250 if (name.compare ("type")) |
|
2251 retval = type; |
|
2252 else if (name.compare ("parent")) |
6874
|
2253 retval = parent.as_octave_value (); |
6807
|
2254 else if (name.compare ("children")) |
|
2255 retval = children; |
|
2256 else if (name.compare ("__modified__")) |
|
2257 retval = __modified__; |
|
2258 else if (name.compare ("cdata")) |
|
2259 retval = cdata; |
|
2260 else if (name.compare ("xdata")) |
|
2261 retval = xdata; |
|
2262 else if (name.compare ("ydata")) |
|
2263 retval = ydata; |
|
2264 else if (name.compare ("zdata")) |
|
2265 retval = zdata; |
7020
|
2266 else if (name.compare ("faces")) |
|
2267 retval = faces; |
|
2268 else if (name.compare ("vertices")) |
|
2269 retval = vertices; |
6807
|
2270 else if (name.compare ("facecolor")) |
|
2271 retval = facecolor; |
|
2272 else if (name.compare ("facealpha")) |
7108
|
2273 retval = facealpha; |
6807
|
2274 else if (name.compare ("egdecolor")) |
|
2275 retval = edgecolor; |
|
2276 else if (name.compare ("linestyle")) |
|
2277 retval = linestyle; |
|
2278 else if (name.compare ("linewidth")) |
|
2279 retval = linewidth; |
|
2280 else if (name.compare ("marker")) |
|
2281 retval = marker; |
|
2282 else if (name.compare ("markeredgecolor")) |
|
2283 retval = markeredgecolor; |
|
2284 else if (name.compare ("markerfacecolor")) |
|
2285 retval = markerfacecolor; |
|
2286 else if (name.compare ("markersize")) |
|
2287 retval = markersize; |
7148
|
2288 else if (name.compare ("keylabel")) |
|
2289 retval = keylabel; |
6807
|
2290 else |
|
2291 warning ("get: invalid property `%s'", name.c_str ()); |
|
2292 |
|
2293 return retval; |
|
2294 } |
|
2295 |
6836
|
2296 property_list::pval_map_type |
6844
|
2297 patch::properties::factory_defaults (void) |
6807
|
2298 { |
|
2299 property_list::pval_map_type m; |
|
2300 |
|
2301 m["cdata"] = Matrix (); |
|
2302 m["xdata"] = Matrix (); |
|
2303 m["ydata"] = Matrix (); |
|
2304 m["zdata"] = Matrix (); |
7020
|
2305 m["faces"] = Matrix (); |
|
2306 m["vertices"] = Matrix (); |
7108
|
2307 m["facecolor"] = color_property (); |
6807
|
2308 m["facealpha"] = 1.0; |
7108
|
2309 m["edgecolor"] = color_property ("black"); |
6807
|
2310 m["linestyle"] = "-"; |
|
2311 m["linewidth"] = 0.5; |
|
2312 m["marker"] = "none"; |
|
2313 m["markeredgecolor"] = "auto"; |
|
2314 m["markerfacecolor"] = "none"; |
|
2315 m["markersize"] = 1; |
7148
|
2316 m["keylabel"] = ""; |
6807
|
2317 |
|
2318 return m; |
|
2319 } |
|
2320 |
6844
|
2321 std::string patch::properties::go_name ("patch"); |
6807
|
2322 |
|
2323 // --------------------------------------------------------------------- |
|
2324 |
6844
|
2325 surface::properties::properties (const graphics_handle& mh, |
|
2326 const graphics_handle& p) |
6705
|
2327 : base_properties (go_name, mh, p), |
|
2328 xdata (Matrix ()), |
|
2329 ydata (Matrix ()), |
|
2330 zdata (Matrix ()), |
7108
|
2331 cdata (Matrix ()), |
|
2332 facecolor (radio_values ("{flat}|none|interp")), |
|
2333 facealpha (1.0), |
|
2334 edgecolor (color_values(0, 0, 0), radio_values ("flat|none|interp")), |
|
2335 linestyle ("-"), |
|
2336 linewidth (0.5), |
|
2337 marker ("none"), |
|
2338 markeredgecolor ("auto"), |
|
2339 markerfacecolor ("none"), |
|
2340 markersize (1), |
6705
|
2341 keylabel ("") |
|
2342 { } |
|
2343 |
|
2344 void |
6844
|
2345 surface::properties::set (const property_name& name, |
|
2346 const octave_value& val) |
6406
|
2347 { |
6705
|
2348 bool modified = true; |
6432
|
2349 |
6705
|
2350 if (name.compare ("parent")) |
|
2351 set_parent (val); |
|
2352 else if (name.compare ("children")) |
|
2353 children = maybe_set_children (children, val); |
|
2354 else if (name.compare ("__modified__")) |
|
2355 { |
|
2356 __modified__ = val.bool_value (); |
|
2357 modified = false; |
6406
|
2358 } |
6705
|
2359 else if (name.compare ("xdata")) |
6874
|
2360 set_xdata (val); |
6705
|
2361 else if (name.compare ("ydata")) |
6874
|
2362 set_ydata (val); |
6705
|
2363 else if (name.compare ("zdata")) |
6874
|
2364 set_zdata (val); |
7108
|
2365 else if (name.compare ("cdata")) |
|
2366 set_cdata (val); |
|
2367 else if (name.compare ("facecolor")) |
|
2368 set_facecolor (val); |
|
2369 else if (name.compare ("facealpha")) |
|
2370 set_facealpha (val); |
|
2371 else if (name.compare ("edgecolor")) |
|
2372 set_edgecolor (val); |
|
2373 else if (name.compare ("linestyle")) |
|
2374 set_linestyle (val); |
|
2375 else if (name.compare ("linewidth")) |
|
2376 set_linewidth (val); |
|
2377 else if (name.compare ("marker")) |
|
2378 set_marker (val); |
|
2379 else if (name.compare ("markeredgecolor")) |
|
2380 set_markeredgecolor (val); |
|
2381 else if (name.compare ("markerfacecolor")) |
|
2382 set_markerfacecolor (val); |
|
2383 else if (name.compare ("markersize")) |
|
2384 set_markersize (val); |
6705
|
2385 else if (name.compare ("keylabel")) |
6874
|
2386 set_keylabel (val); |
6705
|
2387 else |
6406
|
2388 { |
6705
|
2389 modified = false; |
|
2390 warning ("set: invalid property `%s'", name.c_str ()); |
6406
|
2391 } |
|
2392 |
6705
|
2393 if (modified) |
|
2394 mark_modified (); |
|
2395 } |
6406
|
2396 |
6705
|
2397 octave_value |
6844
|
2398 surface::properties::get (void) const |
6705
|
2399 { |
|
2400 Octave_map m; |
6406
|
2401 |
6705
|
2402 m.assign ("type", type); |
6874
|
2403 m.assign ("parent", parent.as_octave_value ()); |
6705
|
2404 m.assign ("children", children); |
|
2405 m.assign ("__modified__", __modified__); |
|
2406 m.assign ("xdata", xdata); |
|
2407 m.assign ("ydata", ydata); |
|
2408 m.assign ("zdata", zdata); |
7108
|
2409 m.assign ("cdata", cdata); |
|
2410 m.assign ("facecolor", facecolor); |
|
2411 m.assign ("facealpha", facealpha); |
|
2412 m.assign ("edgecolor", edgecolor); |
|
2413 m.assign ("linestyle", linestyle); |
|
2414 m.assign ("linewidth", linewidth); |
|
2415 m.assign ("marker", marker); |
|
2416 m.assign ("markeredgecolor", markeredgecolor); |
|
2417 m.assign ("markerface", markerfacecolor); |
|
2418 m.assign ("markersize", markersize); |
6705
|
2419 m.assign ("keylabel", keylabel); |
6406
|
2420 |
6705
|
2421 return m; |
|
2422 } |
6406
|
2423 |
6705
|
2424 octave_value |
6844
|
2425 surface::properties::get (const property_name& name) const |
6705
|
2426 { |
|
2427 octave_value retval; |
6406
|
2428 |
6705
|
2429 if (name.compare ("type")) |
|
2430 retval = type; |
|
2431 else if (name.compare ("parent")) |
6874
|
2432 retval = parent.as_octave_value (); |
6705
|
2433 else if (name.compare ("children")) |
|
2434 retval = children; |
|
2435 else if (name.compare ("__modified__")) |
|
2436 retval = __modified__; |
|
2437 else if (name.compare ("xdata")) |
|
2438 retval = xdata; |
|
2439 else if (name.compare ("ydata")) |
|
2440 retval = ydata; |
|
2441 else if (name.compare ("zdata")) |
|
2442 retval = zdata; |
7108
|
2443 else if (name.compare ("cdata")) |
|
2444 retval = cdata; |
|
2445 else if (name.compare ("facecolor")) |
|
2446 retval = facecolor; |
|
2447 else if (name.compare ("facealpha")) |
|
2448 retval = facealpha; |
|
2449 else if (name.compare ("edgecolor")) |
|
2450 retval = edgecolor; |
|
2451 else if (name.compare ("linestyle")) |
|
2452 retval = linestyle; |
|
2453 else if (name.compare ("linewidth")) |
|
2454 retval = linewidth; |
|
2455 else if (name.compare ("marker")) |
|
2456 retval = marker; |
|
2457 else if (name.compare ("markeredgecolor")) |
|
2458 retval = markeredgecolor; |
|
2459 else if (name.compare ("markerfacecolor")) |
|
2460 retval = markerfacecolor; |
|
2461 else if (name.compare ("markersize")) |
|
2462 retval = markersize; |
6705
|
2463 else if (name.compare ("keylabel")) |
|
2464 retval = keylabel; |
|
2465 else |
|
2466 warning ("get: invalid property `%s'", name.c_str ()); |
6406
|
2467 |
6705
|
2468 return retval; |
|
2469 } |
6406
|
2470 |
6705
|
2471 property_list::pval_map_type |
6844
|
2472 surface::properties::factory_defaults (void) |
6705
|
2473 { |
|
2474 property_list::pval_map_type m; |
6406
|
2475 |
6705
|
2476 m["xdata"] = Matrix (); |
|
2477 m["ydata"] = Matrix (); |
|
2478 m["zdata"] = Matrix (); |
7108
|
2479 m["cdata"] = Matrix (); |
|
2480 m["facecolor"] = color_property (); |
|
2481 m["facealpha"] = 1.0; |
|
2482 m["edgecolor"] = color_property ("black"); |
|
2483 m["linestyle"] = "-"; |
|
2484 m["linewidth"] = 0.5; |
|
2485 m["marker"] = "none"; |
|
2486 m["markeredgecolor"] = "auto"; |
|
2487 m["markerfacecolor"] = "none"; |
|
2488 m["markersize"] = 1; |
6705
|
2489 m["keylabel"] = ""; |
6406
|
2490 |
6705
|
2491 return m; |
|
2492 } |
6406
|
2493 |
6844
|
2494 std::string surface::properties::go_name ("surface"); |
6406
|
2495 |
|
2496 // --------------------------------------------------------------------- |
|
2497 |
|
2498 octave_value |
|
2499 base_graphics_object::get_default (const property_name& name) const |
|
2500 { |
|
2501 graphics_handle parent = get_parent (); |
|
2502 graphics_object parent_obj = gh_manager::get_object (parent); |
|
2503 |
|
2504 return parent_obj.get_default (type () + name); |
|
2505 } |
|
2506 |
|
2507 octave_value |
|
2508 base_graphics_object::get_factory_default (const property_name& name) const |
|
2509 { |
|
2510 graphics_object parent_obj = gh_manager::get_object (0); |
|
2511 |
|
2512 return parent_obj.get_factory_default (type () + name); |
|
2513 } |
|
2514 |
|
2515 gh_manager::gh_manager (void) |
|
2516 : handle_map (), handle_free_list (), next_handle (-1) |
|
2517 { |
|
2518 handle_map[0] = graphics_object (new root_figure ()); |
|
2519 } |
|
2520 |
|
2521 graphics_handle |
|
2522 gh_manager::do_make_graphics_handle (const std::string& go_name, |
|
2523 const graphics_handle& p) |
|
2524 { |
|
2525 graphics_handle h = get_handle (go_name); |
|
2526 |
|
2527 base_graphics_object *go = 0; |
|
2528 |
|
2529 if (go_name == "figure") |
|
2530 go = new figure (h, p); |
|
2531 else if (go_name == "axes") |
|
2532 go = new axes (h, p); |
|
2533 else if (go_name == "line") |
|
2534 go = new line (h, p); |
|
2535 else if (go_name == "text") |
|
2536 go = new text (h, p); |
|
2537 else if (go_name == "image") |
|
2538 go = new image (h, p); |
6807
|
2539 else if (go_name == "patch") |
|
2540 go = new patch (h, p); |
6406
|
2541 else if (go_name == "surface") |
|
2542 go = new surface (h, p); |
|
2543 if (go) |
|
2544 handle_map[h] = graphics_object (go); |
|
2545 else |
|
2546 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", |
|
2547 go_name.c_str ()); |
|
2548 |
|
2549 return h; |
|
2550 } |
|
2551 |
|
2552 graphics_handle |
|
2553 gh_manager::do_make_figure_handle (double val) |
|
2554 { |
|
2555 graphics_handle h = val; |
|
2556 |
|
2557 handle_map[h] = graphics_object (new figure (h, 0)); |
|
2558 |
|
2559 return h; |
|
2560 } |
|
2561 |
|
2562 void |
|
2563 gh_manager::do_push_figure (const graphics_handle& h) |
|
2564 { |
|
2565 do_pop_figure (h); |
|
2566 |
|
2567 figure_list.push_front (h); |
|
2568 } |
|
2569 |
|
2570 void |
|
2571 gh_manager::do_pop_figure (const graphics_handle& h) |
|
2572 { |
|
2573 for (figure_list_iterator p = figure_list.begin (); |
|
2574 p != figure_list.end (); |
|
2575 p++) |
|
2576 { |
|
2577 if (*p == h) |
|
2578 { |
|
2579 figure_list.erase (p); |
|
2580 break; |
|
2581 } |
|
2582 } |
|
2583 } |
|
2584 |
|
2585 property_list::plist_map_type |
|
2586 root_figure::init_factory_properties (void) |
|
2587 { |
|
2588 property_list::plist_map_type plist_map; |
|
2589 |
6844
|
2590 plist_map["figure"] = figure::properties::factory_defaults (); |
|
2591 plist_map["axes"] = axes::properties::factory_defaults (); |
|
2592 plist_map["line"] = line::properties::factory_defaults (); |
|
2593 plist_map["text"] = text::properties::factory_defaults (); |
|
2594 plist_map["image"] = image::properties::factory_defaults (); |
|
2595 plist_map["patch"] = patch::properties::factory_defaults (); |
|
2596 plist_map["surface"] = surface::properties::factory_defaults (); |
6406
|
2597 |
|
2598 return plist_map; |
|
2599 } |
|
2600 |
|
2601 // --------------------------------------------------------------------- |
|
2602 |
|
2603 DEFUN (ishandle, args, , |
|
2604 "-*- texinfo -*-\n\ |
6678
|
2605 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406
|
2606 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
|
2607 @end deftypefn") |
|
2608 { |
|
2609 octave_value retval; |
|
2610 |
|
2611 if (args.length () == 1) |
|
2612 retval = is_handle (args(0)); |
|
2613 else |
|
2614 print_usage (); |
|
2615 |
|
2616 return retval; |
|
2617 } |
|
2618 |
|
2619 DEFUN (set, args, , |
|
2620 "-*- texinfo -*-\n\ |
6678
|
2621 @deftypefn {Built-in Function} {} set (@var{h}, @var{p}, @var{v}, @dots{})\n\ |
6732
|
2622 Set the named property value or vector @var{p} to the value @var{v}\n\ |
6894
|
2623 for the graphics handle @var{h}.\n\ |
6406
|
2624 @end deftypefn") |
|
2625 { |
|
2626 octave_value retval; |
|
2627 |
|
2628 int nargin = args.length (); |
|
2629 |
|
2630 if (nargin > 0) |
|
2631 { |
6732
|
2632 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2633 |
|
2634 if (! error_state) |
6732
|
2635 { |
6733
|
2636 bool request_drawnow = false; |
|
2637 |
6732
|
2638 for (octave_idx_type n = 0; n < hcv.length (); n++) |
|
2639 { |
|
2640 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2641 |
6732
|
2642 if (obj) |
|
2643 { |
|
2644 obj.set (args.splice (0, 1)); |
6406
|
2645 |
6733
|
2646 request_drawnow = true; |
6732
|
2647 } |
|
2648 else |
6733
|
2649 { |
|
2650 error ("set: invalid handle (= %g)", hcv(n)); |
|
2651 break; |
|
2652 } |
6732
|
2653 } |
6733
|
2654 |
|
2655 if (! error_state && request_drawnow) |
|
2656 feval ("__request_drawnow__"); |
6732
|
2657 } |
6406
|
2658 else |
6732
|
2659 error ("set: expecting graphics handle as first argument"); |
6406
|
2660 } |
|
2661 else |
|
2662 print_usage (); |
|
2663 |
|
2664 return retval; |
|
2665 } |
|
2666 |
|
2667 DEFUN (get, args, , |
|
2668 "-*- texinfo -*-\n\ |
6678
|
2669 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406
|
2670 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
|
2671 If @var{p} is omitted, return the complete property list for @var{h}.\n\ |
6732
|
2672 If @var{h} is a vector, return a cell array including the property\n\ |
|
2673 values or lists respectively.\n\ |
6406
|
2674 @end deftypefn") |
|
2675 { |
|
2676 octave_value retval; |
6732
|
2677 octave_value_list vlist; |
6406
|
2678 |
|
2679 int nargin = args.length (); |
|
2680 |
|
2681 if (nargin == 1 || nargin == 2) |
|
2682 { |
6732
|
2683 ColumnVector hcv (args(0).vector_value ()); |
6406
|
2684 |
|
2685 if (! error_state) |
6732
|
2686 { |
6733
|
2687 octave_idx_type len = hcv.length (); |
|
2688 |
|
2689 vlist.resize (len); |
|
2690 |
|
2691 for (octave_idx_type n = 0; n < len; n++) |
6732
|
2692 { |
|
2693 graphics_object obj = gh_manager::get_object (hcv(n)); |
6406
|
2694 |
6732
|
2695 if (obj) |
|
2696 { |
|
2697 if (nargin == 1) |
|
2698 vlist(n) = obj.get (); |
|
2699 else |
|
2700 { |
|
2701 property_name property = args(1).string_value (); |
6406
|
2702 |
6732
|
2703 if (! error_state) |
|
2704 vlist(n) = obj.get (property); |
|
2705 else |
6733
|
2706 { |
|
2707 error ("get: expecting property name as second argument"); |
|
2708 break; |
|
2709 } |
6732
|
2710 } |
|
2711 } |
|
2712 else |
6733
|
2713 { |
|
2714 error ("get: invalid handle (= %g)", hcv(n)); |
|
2715 break; |
|
2716 } |
6732
|
2717 } |
|
2718 } |
6406
|
2719 else |
6732
|
2720 error ("get: expecting graphics handle as first argument"); |
6406
|
2721 } |
|
2722 else |
|
2723 print_usage (); |
|
2724 |
6733
|
2725 if (! error_state) |
6732
|
2726 { |
6733
|
2727 octave_idx_type len = vlist.length (); |
|
2728 |
|
2729 if (len > 1) |
|
2730 retval = Cell (vlist); |
|
2731 else if (len == 1) |
|
2732 retval = vlist(0); |
6732
|
2733 } |
|
2734 |
6406
|
2735 return retval; |
|
2736 } |
|
2737 |
|
2738 static octave_value |
|
2739 make_graphics_object (const std::string& go_name, |
6874
|
2740 const octave_value_list& args) |
6406
|
2741 { |
|
2742 octave_value retval; |
|
2743 |
|
2744 double val = args(0).double_value (); |
|
2745 |
|
2746 if (! error_state) |
|
2747 { |
|
2748 graphics_handle parent = gh_manager::lookup (val); |
|
2749 |
7056
|
2750 if (parent.ok ()) |
6406
|
2751 { |
|
2752 graphics_handle h |
|
2753 = gh_manager::make_graphics_handle (go_name, parent); |
|
2754 |
|
2755 if (! error_state) |
|
2756 { |
|
2757 adopt (parent, h); |
|
2758 |
|
2759 xset (h, args.splice (0, 1)); |
|
2760 |
6874
|
2761 retval = h.value (); |
6406
|
2762 } |
|
2763 else |
|
2764 error ("__go%s__: unable to create graphics handle", |
|
2765 go_name.c_str ()); |
|
2766 } |
|
2767 else |
|
2768 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2769 } |
|
2770 else |
|
2771 error ("__go_%s__: invalid parent", go_name.c_str ()); |
|
2772 |
|
2773 return retval; |
|
2774 } |
|
2775 |
|
2776 DEFUN (__go_figure__, args, , |
|
2777 "-*- texinfo -*-\n\ |
|
2778 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ |
6945
|
2779 Undocumented internal function.\n\ |
6406
|
2780 @end deftypefn") |
|
2781 { |
|
2782 octave_value retval; |
|
2783 |
|
2784 if (args.length () > 0) |
|
2785 { |
|
2786 double val = args(0).double_value (); |
|
2787 |
|
2788 if (! error_state) |
|
2789 { |
|
2790 if (is_figure (val)) |
|
2791 { |
|
2792 graphics_handle h = gh_manager::lookup (val); |
|
2793 |
|
2794 xset (h, args.splice (0, 1)); |
|
2795 |
6874
|
2796 retval = h.value (); |
6406
|
2797 } |
|
2798 else |
|
2799 { |
|
2800 graphics_handle h = octave_NaN; |
|
2801 |
|
2802 if (xisnan (val)) |
|
2803 h = gh_manager::make_graphics_handle ("figure", 0); |
|
2804 else if (val > 0 && D_NINT (val) == val) |
|
2805 h = gh_manager::make_figure_handle (val); |
|
2806 else |
|
2807 error ("__go_figure__: invalid figure number"); |
|
2808 |
7056
|
2809 if (! error_state && h.ok ()) |
6406
|
2810 { |
|
2811 adopt (0, h); |
|
2812 |
|
2813 xset (h, args.splice (0, 1)); |
|
2814 |
6874
|
2815 retval = h.value (); |
6406
|
2816 } |
|
2817 else |
|
2818 error ("__go_figure__: failed to create figure handle"); |
|
2819 } |
|
2820 } |
|
2821 else |
|
2822 error ("__go_figure__: expecting figure number to be double value"); |
|
2823 } |
|
2824 else |
|
2825 print_usage (); |
|
2826 |
|
2827 return retval; |
|
2828 } |
|
2829 |
|
2830 #define GO_BODY(TYPE) \ |
|
2831 octave_value retval; \ |
|
2832 \ |
|
2833 if (args.length () > 0) \ |
|
2834 retval = make_graphics_object (#TYPE, args); \ |
|
2835 else \ |
|
2836 print_usage (); \ |
|
2837 \ |
|
2838 return retval |
|
2839 |
|
2840 DEFUN (__go_axes__, args, , |
|
2841 "-*- texinfo -*-\n\ |
|
2842 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ |
6945
|
2843 Undocumented internal function.\n\ |
6406
|
2844 @end deftypefn") |
|
2845 { |
|
2846 GO_BODY (axes); |
|
2847 } |
|
2848 |
|
2849 DEFUN (__go_line__, args, , |
|
2850 "-*- texinfo -*-\n\ |
|
2851 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ |
6945
|
2852 Undocumented internal function.\n\ |
6406
|
2853 @end deftypefn") |
|
2854 { |
|
2855 GO_BODY (line); |
|
2856 } |
|
2857 |
|
2858 DEFUN (__go_text__, args, , |
|
2859 "-*- texinfo -*-\n\ |
|
2860 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ |
6945
|
2861 Undocumented internal function.\n\ |
6406
|
2862 @end deftypefn") |
|
2863 { |
|
2864 GO_BODY (text); |
|
2865 } |
|
2866 |
|
2867 DEFUN (__go_image__, args, , |
|
2868 "-*- texinfo -*-\n\ |
|
2869 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ |
6945
|
2870 Undocumented internal function.\n\ |
6406
|
2871 @end deftypefn") |
|
2872 { |
|
2873 GO_BODY (image); |
|
2874 } |
|
2875 |
|
2876 DEFUN (__go_surface__, args, , |
|
2877 "-*- texinfo -*-\n\ |
|
2878 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ |
6945
|
2879 Undocumented internal function.\n\ |
6406
|
2880 @end deftypefn") |
|
2881 { |
|
2882 GO_BODY (surface); |
|
2883 } |
|
2884 |
6807
|
2885 DEFUN (__go_patch__, args, , |
|
2886 "-*- texinfo -*-\n\ |
|
2887 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ |
6945
|
2888 Undocumented internal function.\n\ |
6807
|
2889 @end deftypefn") |
|
2890 { |
|
2891 GO_BODY (patch); |
|
2892 } |
|
2893 |
6406
|
2894 DEFUN (__go_delete__, args, , |
|
2895 "-*- texinfo -*-\n\ |
|
2896 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ |
6945
|
2897 Undocumented internal function.\n\ |
6406
|
2898 @end deftypefn") |
|
2899 { |
|
2900 octave_value_list retval; |
|
2901 |
|
2902 if (args.length () == 1) |
|
2903 { |
|
2904 graphics_handle h = octave_NaN; |
|
2905 |
|
2906 double val = args(0).double_value (); |
|
2907 |
|
2908 if (! error_state) |
|
2909 { |
|
2910 h = gh_manager::lookup (val); |
|
2911 |
7056
|
2912 if (h.ok ()) |
6406
|
2913 { |
|
2914 graphics_object obj = gh_manager::get_object (h); |
|
2915 |
|
2916 graphics_handle parent_h = obj.get_parent (); |
|
2917 |
|
2918 graphics_object parent_obj = gh_manager::get_object (parent_h); |
|
2919 |
|
2920 parent_obj.remove_child (h); |
|
2921 |
|
2922 gh_manager::free (h); |
|
2923 } |
|
2924 else |
|
2925 error ("delete: invalid graphics object (= %g)", val); |
|
2926 } |
|
2927 else |
|
2928 error ("delete: invalid graphics object"); |
|
2929 } |
|
2930 else |
|
2931 print_usage (); |
|
2932 |
|
2933 return retval; |
|
2934 } |
|
2935 |
|
2936 DEFUN (__go_axes_init__, args, , |
|
2937 "-*- texinfo -*-\n\ |
|
2938 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ |
6945
|
2939 Undocumented internal function.\n\ |
6406
|
2940 @end deftypefn") |
|
2941 { |
|
2942 octave_value retval; |
|
2943 |
|
2944 int nargin = args.length (); |
|
2945 |
|
2946 std::string mode = ""; |
|
2947 |
|
2948 if (nargin == 2) |
|
2949 { |
|
2950 mode = args(1).string_value (); |
|
2951 |
|
2952 if (error_state) |
|
2953 return retval; |
|
2954 } |
|
2955 |
|
2956 if (nargin == 1 || nargin == 2) |
|
2957 { |
|
2958 graphics_handle h = octave_NaN; |
|
2959 |
|
2960 double val = args(0).double_value (); |
|
2961 |
|
2962 if (! error_state) |
|
2963 { |
|
2964 h = gh_manager::lookup (val); |
|
2965 |
7056
|
2966 if (h.ok ()) |
6406
|
2967 { |
|
2968 graphics_object obj = gh_manager::get_object (h); |
|
2969 |
|
2970 obj.set_defaults (mode); |
|
2971 } |
|
2972 else |
|
2973 error ("__go_axes_init__: invalid graphics object (= %g)", val); |
|
2974 } |
|
2975 else |
|
2976 error ("__go_axes_init__: invalid graphics object"); |
|
2977 } |
|
2978 else |
|
2979 print_usage (); |
|
2980 |
|
2981 return retval; |
|
2982 } |
|
2983 |
|
2984 DEFUN (__go_handles__, , , |
|
2985 "-*- texinfo -*-\n\ |
|
2986 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ |
6945
|
2987 Undocumented internal function.\n\ |
6406
|
2988 @end deftypefn") |
|
2989 { |
6425
|
2990 return octave_value (gh_manager::handle_list ()); |
|
2991 } |
|
2992 |
|
2993 DEFUN (__go_figure_handles__, , , |
|
2994 "-*- texinfo -*-\n\ |
|
2995 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ |
6945
|
2996 Undocumented internal function.\n\ |
6425
|
2997 @end deftypefn") |
|
2998 { |
|
2999 return octave_value (gh_manager::figure_handle_list ()); |
6406
|
3000 } |
|
3001 |
6595
|
3002 octave_value |
|
3003 get_property_from_handle (double handle, const std::string &property, |
|
3004 const std::string &func) |
|
3005 { |
|
3006 graphics_object obj = gh_manager::get_object (handle); |
|
3007 octave_value retval; |
|
3008 |
|
3009 if (obj) |
|
3010 { |
|
3011 property_name p = std::string (property); |
|
3012 retval = obj.get (p); |
|
3013 } |
|
3014 else |
|
3015 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
3016 |
|
3017 return retval; |
|
3018 } |
|
3019 |
|
3020 bool |
|
3021 set_property_in_handle (double handle, const std::string &property, |
|
3022 const octave_value &arg, const std::string &func) |
|
3023 { |
|
3024 graphics_object obj = gh_manager::get_object (handle); |
|
3025 int ret = false; |
|
3026 |
|
3027 if (obj) |
|
3028 { |
|
3029 property_name p = std::string (property); |
|
3030 obj.set (p, arg); |
|
3031 if (!error_state) |
|
3032 ret = true; |
|
3033 } |
|
3034 else |
|
3035 error ("%s: invalid handle (= %g)", func.c_str(), handle); |
|
3036 |
|
3037 return ret; |
|
3038 } |
|
3039 |
6406
|
3040 /* |
|
3041 ;;; Local Variables: *** |
|
3042 ;;; mode: C++ *** |
|
3043 ;;; End: *** |
|
3044 */ |