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