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