6874
|
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. |
6874
|
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/>. |
6874
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (graphics_h) |
|
24 #define graphics_h 1 |
|
25 |
|
26 #ifdef HAVE_CONFIG_H |
|
27 #include <config.h> |
|
28 #endif |
|
29 |
|
30 #include <cctype> |
|
31 |
|
32 #include <algorithm> |
|
33 #include <list> |
|
34 #include <map> |
|
35 #include <set> |
|
36 #include <string> |
|
37 |
6890
|
38 #include "gripes.h" |
6874
|
39 #include "oct-map.h" |
|
40 #include "ov.h" |
|
41 |
7189
|
42 class caseless_str : public std::string |
|
43 { |
|
44 public: |
|
45 typedef std::string::iterator iterator; |
|
46 typedef std::string::const_iterator const_iterator; |
|
47 |
|
48 caseless_str (void) : std::string () { } |
|
49 caseless_str (const std::string& s) : std::string (s) { } |
|
50 caseless_str (const char *s) : std::string (s) { } |
|
51 |
|
52 caseless_str (const caseless_str& name) : std::string (name) { } |
|
53 |
|
54 caseless_str& operator = (const caseless_str& pname) |
|
55 { |
|
56 std::string::operator = (pname); |
|
57 return *this; |
|
58 } |
|
59 |
|
60 operator std::string (void) const { return *this; } |
|
61 |
|
62 // Case-insensitive comparison. |
|
63 bool compare (const std::string& s, size_t limit = NPOS) const |
|
64 { |
|
65 const_iterator p1 = begin (); |
|
66 const_iterator p2 = s.begin (); |
|
67 |
|
68 size_t k = 0; |
|
69 |
|
70 while (p1 != end () && p2 != s.end () && k++ < limit) |
|
71 { |
|
72 if (std::tolower (*p1) != std::tolower (*p2)) |
|
73 return false; |
|
74 |
|
75 *p1++; |
|
76 *p2++; |
|
77 } |
|
78 |
|
79 return (limit == NPOS) ? size () == s.size () : k == limit; |
|
80 } |
|
81 }; |
|
82 |
|
83 // --------------------------------------------------------------------- |
|
84 |
6874
|
85 class graphics_handle |
|
86 { |
|
87 public: |
|
88 graphics_handle (void) : val (octave_NaN) { } |
|
89 |
|
90 graphics_handle (const octave_value& a); |
|
91 |
|
92 graphics_handle (int a) : val (a) { } |
|
93 |
|
94 graphics_handle (double a) : val (a) { } |
|
95 |
|
96 graphics_handle (const graphics_handle& a) : val (a.val) { } |
|
97 |
|
98 graphics_handle& operator = (const graphics_handle& a) |
|
99 { |
|
100 if (&a != this) |
|
101 val = a.val; |
|
102 |
|
103 return *this; |
|
104 } |
|
105 |
|
106 ~graphics_handle (void) { } |
|
107 |
|
108 double value (void) const { return val; } |
|
109 |
|
110 octave_value as_octave_value (void) const |
|
111 { |
|
112 return ok () ? octave_value (val) : octave_value (Matrix ()); |
|
113 } |
|
114 |
|
115 graphics_handle operator ++ (void) |
|
116 { |
|
117 ++val; |
|
118 return *this; |
|
119 } |
|
120 |
|
121 graphics_handle operator ++ (int) |
|
122 { |
|
123 graphics_handle h = *this; |
|
124 ++val; |
|
125 return h; |
|
126 } |
|
127 |
|
128 graphics_handle operator -- (void) |
|
129 { |
|
130 --val; |
|
131 return *this; |
|
132 } |
|
133 |
|
134 graphics_handle operator -- (int) |
|
135 { |
|
136 graphics_handle h = *this; |
|
137 --val; |
|
138 return h; |
|
139 } |
|
140 |
|
141 bool ok (void) const { return ! xisnan (val); } |
|
142 |
|
143 private: |
|
144 double val; |
|
145 }; |
|
146 |
|
147 inline bool |
|
148 operator == (const graphics_handle& a, const graphics_handle& b) |
|
149 { |
|
150 return a.value () == b.value (); |
|
151 } |
|
152 |
|
153 inline bool |
|
154 operator != (const graphics_handle& a, const graphics_handle& b) |
|
155 { |
|
156 return a.value () != b.value (); |
|
157 } |
|
158 |
|
159 inline bool |
|
160 operator < (const graphics_handle& a, const graphics_handle& b) |
|
161 { |
|
162 return a.value () < b.value (); |
|
163 } |
|
164 |
|
165 inline bool |
|
166 operator <= (const graphics_handle& a, const graphics_handle& b) |
|
167 { |
|
168 return a.value () <= b.value (); |
|
169 } |
|
170 |
|
171 inline bool |
|
172 operator >= (const graphics_handle& a, const graphics_handle& b) |
|
173 { |
|
174 return a.value () >= b.value (); |
|
175 } |
|
176 |
|
177 inline bool |
|
178 operator > (const graphics_handle& a, const graphics_handle& b) |
|
179 { |
|
180 return a.value () > b.value (); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------------------- |
|
184 |
7363
|
185 class property; |
|
186 |
|
187 class base_property |
|
188 { |
|
189 public: |
|
190 friend class property; |
|
191 |
|
192 public: |
|
193 base_property (void) : count (0) { } |
|
194 |
|
195 base_property (const std::string& s, const graphics_handle& h) |
|
196 : count (0), name (s), parent (h), hidden (false) { } |
|
197 |
|
198 base_property (const base_property& p) |
|
199 : count (0), name (p.name), parent (p.parent), hidden (p.hidden) { } |
|
200 |
|
201 virtual ~base_property (void) { } |
|
202 |
|
203 bool ok (void) const { return parent.ok (); } |
|
204 |
|
205 std::string get_name (void) const { return name; } |
|
206 |
|
207 void set_name (const std::string& s) { name = s; } |
|
208 |
|
209 graphics_handle get_parent (void) const { return parent; } |
|
210 |
|
211 void set_parent (const graphics_handle &h) { parent = h; } |
|
212 |
|
213 bool is_hidden (void) const { return hidden; } |
|
214 |
|
215 void set_hidden (bool flag) { hidden = flag; } |
|
216 |
7364
|
217 virtual void set (const octave_value&) |
7363
|
218 { error ("set: invalid property \"%s\"", name.c_str ()); } |
|
219 |
|
220 virtual octave_value get (void) const |
|
221 { |
|
222 error ("get: invalid property \"%s\"", name.c_str ()); |
|
223 return octave_value (); |
|
224 } |
|
225 |
|
226 base_property& operator = (const octave_value& val) |
|
227 { |
|
228 set (val); |
|
229 return *this; |
|
230 } |
|
231 |
|
232 private: |
|
233 int count; |
|
234 std::string name; |
|
235 graphics_handle parent; |
|
236 bool hidden; |
|
237 }; |
|
238 |
|
239 // --------------------------------------------------------------------- |
|
240 |
|
241 class string_property : public base_property |
|
242 { |
|
243 public: |
|
244 string_property (const std::string& s, const graphics_handle& h, |
|
245 const std::string& val = "") |
|
246 : base_property (s, h), str (val) { } |
|
247 |
|
248 string_property (const string_property& p) |
|
249 : base_property (p), str (p.str) { } |
|
250 |
|
251 void set (const octave_value& val) |
|
252 { |
|
253 if (val.is_string ()) |
|
254 str = val.string_value (); |
|
255 else |
|
256 error ("set: invalid string property value for \"%s\"", |
|
257 get_name ().c_str ()); |
|
258 } |
|
259 |
|
260 octave_value get (void) const |
|
261 { return octave_value (str); } |
|
262 |
|
263 std::string string_value (void) const { return str; } |
|
264 |
|
265 string_property& operator = (const octave_value& val) |
|
266 { |
|
267 set (val); |
|
268 return *this; |
|
269 } |
|
270 |
|
271 private: |
|
272 std::string str; |
|
273 }; |
|
274 |
|
275 // --------------------------------------------------------------------- |
|
276 |
|
277 class radio_values |
|
278 { |
|
279 public: |
|
280 OCTINTERP_API radio_values (const std::string& opt_string = std::string ()); |
|
281 |
|
282 radio_values (const radio_values& a) |
|
283 : default_val (a.default_val), possible_vals (a.possible_vals) { } |
|
284 |
|
285 radio_values& operator = (const radio_values& a) |
|
286 { |
|
287 if (&a != this) |
|
288 { |
|
289 default_val = a.default_val; |
|
290 possible_vals = a.possible_vals; |
|
291 } |
|
292 |
|
293 return *this; |
|
294 } |
|
295 |
|
296 std::string default_value (void) const { return default_val; } |
|
297 |
|
298 bool validate (const std::string& val) |
|
299 { |
|
300 bool retval = true; |
|
301 |
|
302 if (! contains (val)) |
|
303 { |
|
304 error ("invalid value = %s", val.c_str ()); |
|
305 retval = false; |
|
306 } |
|
307 |
|
308 return retval; |
|
309 } |
|
310 |
|
311 bool contains (const std::string& val) |
|
312 { |
|
313 return (possible_vals.find (val) != possible_vals.end ()); |
|
314 } |
|
315 |
|
316 private: |
|
317 // Might also want to cache |
|
318 std::string default_val; |
|
319 std::set<caseless_str> possible_vals; |
|
320 }; |
|
321 |
|
322 class radio_property : public base_property |
|
323 { |
|
324 public: |
7364
|
325 radio_property (const std::string& nm, const graphics_handle& h, |
7363
|
326 const radio_values& v = radio_values ()) |
7364
|
327 : base_property (nm, h), |
7363
|
328 vals (v), current_val (v.default_value ()) { } |
|
329 |
7364
|
330 radio_property (const std::string& nm, const graphics_handle& h, |
7363
|
331 const std::string& v) |
7364
|
332 : base_property (nm, h), |
7363
|
333 vals (v), current_val (vals.default_value ()) { } |
|
334 |
7364
|
335 radio_property (const std::string& nm, const graphics_handle& h, |
7363
|
336 const radio_values& v, const std::string& def) |
7364
|
337 : base_property (nm, h), |
7363
|
338 vals (v), current_val (def) { } |
|
339 |
|
340 radio_property (const radio_property& p) |
|
341 : base_property (p), vals (p.vals), current_val (p.current_val) { } |
|
342 |
|
343 void set (const octave_value& newval) |
|
344 { |
|
345 if (newval.is_string ()) |
|
346 { |
|
347 std::string s = newval.string_value (); |
|
348 if (vals.validate (s)) |
|
349 current_val = s; |
|
350 else |
|
351 error ("set: invalid value for radio property \"%s\" (value = %s)", |
|
352 get_name ().c_str (), s.c_str ()); |
|
353 } |
|
354 else |
|
355 error ("set: invalid value for radio property \"%s\"", |
|
356 get_name ().c_str ()); |
|
357 } |
|
358 |
|
359 octave_value get (void) const { return octave_value (current_val); } |
|
360 |
|
361 const std::string& current_value (void) const { return current_val; } |
|
362 |
|
363 bool is (const caseless_str& v) const |
|
364 { return v.compare (current_val); } |
|
365 |
|
366 radio_property& operator = (const octave_value& val) |
|
367 { |
|
368 set (val); |
|
369 return *this; |
|
370 } |
|
371 |
|
372 private: |
|
373 radio_values vals; |
|
374 std::string current_val; |
|
375 }; |
|
376 |
|
377 // --------------------------------------------------------------------- |
|
378 |
|
379 class color_values |
|
380 { |
|
381 public: |
|
382 color_values (double r = 0, double g = 0, double b = 1) |
|
383 : xrgb (1, 3) |
|
384 { |
|
385 xrgb(0) = r; |
|
386 xrgb(1) = g; |
|
387 xrgb(2) = b; |
|
388 |
|
389 validate (); |
|
390 } |
|
391 |
|
392 color_values (std::string str) |
|
393 : xrgb (1, 3) |
|
394 { |
|
395 if (! str2rgb (str)) |
|
396 error ("invalid color specification: %s", str.c_str ()); |
|
397 } |
|
398 |
|
399 color_values (const color_values& c) |
|
400 : xrgb (c.xrgb) |
|
401 { } |
|
402 |
|
403 color_values& operator = (const color_values& c) |
|
404 { |
|
405 if (&c != this) |
|
406 xrgb = c.xrgb; |
|
407 |
|
408 return *this; |
|
409 } |
|
410 |
|
411 Matrix rgb (void) const { return xrgb; } |
|
412 |
|
413 operator octave_value (void) const { return xrgb; } |
|
414 |
|
415 void validate (void) const |
|
416 { |
|
417 for (int i = 0; i < 3; i++) |
|
418 { |
|
419 if (xrgb(i) < 0 || xrgb(i) > 1) |
|
420 { |
|
421 error ("invalid RGB color specification"); |
|
422 break; |
|
423 } |
|
424 } |
|
425 } |
|
426 |
|
427 private: |
|
428 Matrix xrgb; |
|
429 |
|
430 OCTINTERP_API bool str2rgb (std::string str); |
|
431 }; |
|
432 |
|
433 class color_property : public base_property |
|
434 { |
|
435 public: |
|
436 color_property (const color_values& c, const radio_values& v) |
|
437 : base_property ("", graphics_handle ()), |
|
438 current_type (color_t), color_val (c), radio_val (v), |
|
439 current_val (v.default_value ()) |
|
440 { } |
|
441 |
7364
|
442 color_property (const std::string& nm, const graphics_handle& h, |
7363
|
443 const color_values& c = color_values (), |
|
444 const radio_values& v = radio_values ()) |
7364
|
445 : base_property (nm, h), |
7363
|
446 current_type (color_t), color_val (c), radio_val (v), |
|
447 current_val (v.default_value ()) |
|
448 { } |
|
449 |
7364
|
450 color_property (const std::string& nm, const graphics_handle& h, |
7363
|
451 const radio_values& v) |
7364
|
452 : base_property (nm, h), |
7363
|
453 current_type (radio_t), color_val (color_values ()), radio_val (v), |
|
454 current_val (v.default_value ()) |
|
455 { } |
|
456 |
7364
|
457 color_property (const std::string& nm, const graphics_handle& h, |
7363
|
458 const std::string& v) |
7364
|
459 : base_property (nm, h), |
7363
|
460 current_type (radio_t), color_val (color_values ()), radio_val (v), |
|
461 current_val (radio_val.default_value ()) |
|
462 { } |
|
463 |
7364
|
464 color_property (const std::string& nm, const graphics_handle& h, |
7363
|
465 const color_property& v) |
7364
|
466 : base_property (nm, h), |
7363
|
467 current_type (v.current_type), color_val (v.color_val), |
|
468 radio_val (v.radio_val), current_val (v.current_val) |
|
469 { } |
|
470 |
|
471 color_property (const color_property& p) |
|
472 : base_property (p), current_type (p.current_type), |
|
473 color_val (p.color_val), radio_val (p.radio_val), |
|
474 current_val (p.current_val) { } |
|
475 |
|
476 octave_value get (void) const |
|
477 { |
|
478 if (current_type == color_t) |
|
479 return color_val.rgb (); |
|
480 |
|
481 return current_val; |
|
482 } |
|
483 |
|
484 OCTINTERP_API void set (const octave_value& newval); |
|
485 |
|
486 bool is_rgb (void) const { return (current_type == color_t); } |
|
487 |
|
488 bool is_radio (void) const { return (current_type == radio_t); } |
|
489 |
|
490 bool is (const std::string& v) const |
|
491 { return (is_radio () && current_val == v); } |
|
492 |
|
493 Matrix rgb (void) const |
|
494 { |
|
495 if (current_type != color_t) |
|
496 error ("color has no rgb value"); |
|
497 |
|
498 return color_val.rgb (); |
|
499 } |
|
500 |
|
501 const std::string& current_value (void) const |
|
502 { |
|
503 if (current_type != radio_t) |
|
504 error ("color has no radio value"); |
|
505 |
|
506 return current_val; |
|
507 } |
|
508 |
|
509 color_property& operator = (const octave_value& val) |
|
510 { |
|
511 set (val); |
|
512 return *this; |
|
513 } |
|
514 |
|
515 operator octave_value (void) const { return get (); } |
|
516 |
|
517 private: |
|
518 enum current_enum { color_t, radio_t } current_type; |
|
519 color_values color_val; |
|
520 radio_values radio_val; |
|
521 std::string current_val; |
|
522 }; |
|
523 |
|
524 // --------------------------------------------------------------------- |
|
525 |
|
526 class double_property : public base_property |
|
527 { |
|
528 public: |
7364
|
529 double_property (const std::string& nm, const graphics_handle& h, |
7363
|
530 double d = 0) |
7364
|
531 : base_property (nm, h), |
7363
|
532 current_val (d) { } |
|
533 |
|
534 double_property (const double_property& p) |
|
535 : base_property (p), current_val (p.current_val) { } |
|
536 |
|
537 void set (const octave_value& v) |
|
538 { |
|
539 if (v.is_scalar_type () && v.is_real_type ()) |
|
540 current_val = v.double_value (); |
|
541 else |
|
542 error ("set: invalid value for double property \"%s\"", |
|
543 get_name ().c_str ()); |
|
544 } |
|
545 |
|
546 octave_value get (void) const { return octave_value (current_val); } |
|
547 |
|
548 double double_value (void) const { return current_val; } |
|
549 |
|
550 double_property& operator = (const octave_value& val) |
|
551 { |
|
552 set (val); |
|
553 return *this; |
|
554 } |
|
555 |
|
556 private: |
|
557 double current_val; |
|
558 }; |
|
559 |
|
560 // --------------------------------------------------------------------- |
|
561 |
|
562 class array_property : public base_property |
|
563 { |
|
564 public: |
7364
|
565 array_property (const std::string& nm, const graphics_handle& h, |
7363
|
566 const octave_value& m) |
7364
|
567 : base_property (nm, h), data (m) { } |
7363
|
568 |
|
569 octave_value get (void) const { return data; } |
|
570 |
|
571 void set (const octave_value& v) |
|
572 { |
|
573 if (validate (v)) |
|
574 data = v; |
|
575 else |
|
576 error ("invalid value for array property \"%s\"", |
|
577 get_name ().c_str ()); |
|
578 } |
|
579 |
|
580 void add_constraint (const std::string& type) |
|
581 { type_constraints.push_back (type); } |
|
582 |
|
583 void add_constraint (dim_vector dims) |
|
584 { size_constraints.push_back (dims); } |
|
585 |
|
586 array_property& operator = (const octave_value& val) |
|
587 { |
|
588 set (val); |
|
589 return *this; |
|
590 } |
|
591 |
|
592 private: |
|
593 OCTINTERP_API bool validate (const octave_value& v); |
|
594 |
|
595 private: |
|
596 octave_value data; |
|
597 std::list<std::string> type_constraints; |
|
598 std::list<dim_vector> size_constraints; |
|
599 }; |
|
600 |
|
601 // --------------------------------------------------------------------- |
|
602 |
|
603 class data_property : public base_property |
|
604 { |
|
605 public: |
|
606 data_property (void) |
|
607 : base_property ("", graphics_handle ()) { } |
|
608 |
7364
|
609 data_property (const std::string& nm, const graphics_handle& h, |
7363
|
610 const NDArray& m = NDArray ()) |
7364
|
611 : base_property (nm, h), |
7363
|
612 data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) |
|
613 { |
|
614 get_data_limits (); |
|
615 } |
|
616 |
7364
|
617 data_property (const std::string& nm, const graphics_handle& h, |
7363
|
618 const Matrix& m) |
7364
|
619 : base_property (nm, h), |
7363
|
620 data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) |
|
621 { |
|
622 get_data_limits (); |
|
623 } |
|
624 |
|
625 data_property (const data_property& p) |
|
626 : base_property (p), data (p.data), |
|
627 xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } |
|
628 |
|
629 void set (const octave_value& val) |
|
630 { |
|
631 data = val.array_value (); |
|
632 |
|
633 get_data_limits (); |
|
634 } |
|
635 |
|
636 octave_value get (void) const { return data; } |
|
637 |
|
638 NDArray array_value (void) const { return data; } |
|
639 |
|
640 Matrix matrix_value (void) const { return data.matrix_value (); } |
|
641 |
|
642 double min_val (void) const { return xmin; } |
|
643 double max_val (void) const { return xmax; } |
|
644 double min_pos (void) const { return xminp; } |
|
645 |
|
646 data_property& operator = (const octave_value& val) |
|
647 { |
|
648 set (val); |
|
649 return *this; |
|
650 } |
|
651 |
|
652 private: |
|
653 NDArray data; |
|
654 double xmin; |
|
655 double xmax; |
|
656 double xminp; |
|
657 |
|
658 void get_data_limits (void) |
|
659 { |
|
660 octave_idx_type nel = data.numel (); |
|
661 |
|
662 if (nel > 0) |
|
663 { |
|
664 const double *d = data.data (); |
|
665 |
|
666 for (octave_idx_type i = 0; i < nel; i++) |
|
667 { |
|
668 double val = d[i]; |
|
669 |
|
670 if (! (xisinf (val) || xisnan (val))) |
|
671 { |
|
672 if (val < xmin) |
|
673 xmin = val; |
|
674 |
|
675 if (val > xmax) |
|
676 xmax = val; |
|
677 |
|
678 if (val > 0 && val < xminp) |
|
679 xminp = val; |
|
680 } |
|
681 } |
|
682 } |
|
683 } |
|
684 }; |
|
685 |
|
686 // --------------------------------------------------------------------- |
|
687 |
|
688 class bool_property : public radio_property |
|
689 { |
|
690 public: |
7364
|
691 bool_property (const std::string& nm, const graphics_handle& h, |
7363
|
692 bool val) |
7364
|
693 : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}")) |
7363
|
694 { } |
|
695 |
7364
|
696 bool_property (const std::string& nm, const graphics_handle& h, |
7363
|
697 const char* val) |
7364
|
698 : radio_property (nm, h, radio_values ("on|off"), val) |
7363
|
699 { } |
|
700 |
|
701 bool_property (const bool_property& p) |
|
702 : radio_property (p) { } |
|
703 |
|
704 void set (const octave_value& val) |
|
705 { |
|
706 if (val.is_bool_scalar ()) |
|
707 radio_property::set (val.bool_value () ? "on" : "off"); |
|
708 else |
|
709 radio_property::set (val); |
|
710 } |
|
711 |
|
712 bool is_on (void) const { return is ("on"); } |
|
713 |
|
714 bool_property& operator = (const octave_value& val) |
|
715 { |
|
716 set (val); |
|
717 return *this; |
|
718 } |
|
719 }; |
|
720 |
|
721 // --------------------------------------------------------------------- |
|
722 |
|
723 class handle_property : public base_property |
|
724 { |
|
725 public: |
7364
|
726 handle_property (const std::string& nm, const graphics_handle& h, |
7363
|
727 const graphics_handle& val = graphics_handle ()) |
7364
|
728 : base_property (nm, h), |
7363
|
729 current_val (val) { } |
|
730 |
|
731 handle_property (const handle_property& p) |
|
732 : base_property (p), current_val (p.current_val) { } |
|
733 |
|
734 OCTINTERP_API void set (const octave_value& v); |
|
735 |
|
736 octave_value get (void) const { return current_val.as_octave_value (); } |
|
737 |
|
738 graphics_handle handle_value (void) const { return current_val; } |
|
739 |
|
740 handle_property& operator = (const octave_value& val) |
|
741 { |
|
742 set (val); |
|
743 return *this; |
|
744 } |
|
745 |
|
746 handle_property& operator = (const graphics_handle& h) |
|
747 { |
|
748 set (octave_value (h.value ())); |
|
749 return *this; |
|
750 } |
|
751 |
|
752 private: |
|
753 graphics_handle current_val; |
|
754 }; |
|
755 |
|
756 // --------------------------------------------------------------------- |
|
757 |
|
758 class any_property : public base_property |
|
759 { |
|
760 public: |
7364
|
761 any_property (const std::string& nm, const graphics_handle& h, |
7363
|
762 const octave_value& m = Matrix ()) |
7364
|
763 : base_property (nm, h), data (m) { } |
7363
|
764 |
|
765 octave_value get (void) const { return data; } |
|
766 |
|
767 void set (const octave_value& v) { data = v; } |
|
768 |
|
769 any_property& operator = (const octave_value& val) |
|
770 { |
|
771 set (val); |
|
772 return *this; |
|
773 } |
|
774 |
|
775 private: |
|
776 octave_value data; |
|
777 }; |
|
778 |
|
779 // --------------------------------------------------------------------- |
|
780 |
|
781 class callback_property : public base_property |
|
782 { |
|
783 public: |
7364
|
784 callback_property (const std::string& nm, const graphics_handle& h, |
7363
|
785 const octave_value& m) |
7364
|
786 : base_property (nm, h), callback (m) { } |
7363
|
787 |
|
788 octave_value get (void) const { return callback; } |
|
789 |
|
790 void set (const octave_value& v) |
|
791 { |
|
792 if (validate (v)) |
|
793 callback = v; |
|
794 else |
|
795 error ("invalid value for callback property \"%s\"", |
|
796 get_name ().c_str ()); |
|
797 } |
|
798 |
7367
|
799 OCTINTERP_API void execute (const octave_value& data = octave_value ()) const; |
7363
|
800 |
|
801 callback_property& operator = (const octave_value& val) |
|
802 { |
|
803 set (val); |
|
804 return *this; |
|
805 } |
|
806 |
|
807 private: |
|
808 OCTINTERP_API bool validate (const octave_value& v) const; |
|
809 |
|
810 private: |
|
811 octave_value callback; |
|
812 }; |
|
813 |
|
814 // --------------------------------------------------------------------- |
|
815 |
|
816 class property |
|
817 { |
|
818 public: |
|
819 property (void) : rep (new base_property ("", graphics_handle ())) |
|
820 { rep->count++; } |
|
821 |
|
822 property (base_property *bp, bool persist = false) : rep (bp) |
|
823 { rep->count++; if (persist) rep->count++; } |
|
824 |
|
825 property (const property& p) |
|
826 { |
|
827 rep = p.rep; |
|
828 rep->count++; |
|
829 } |
|
830 |
|
831 ~property (void) |
|
832 { |
|
833 if (--rep->count <= 0) |
|
834 delete rep; |
|
835 } |
|
836 |
|
837 bool ok (void) const |
|
838 { return rep->ok (); } |
|
839 |
|
840 std::string get_name (void) const |
|
841 { return rep->get_name (); } |
|
842 |
|
843 void set_name (const std::string& name) |
|
844 { rep->set_name (name); } |
|
845 |
|
846 graphics_handle get_parent (void) const |
|
847 { return rep->get_parent (); } |
|
848 |
|
849 void set_parent (const graphics_handle& h) |
|
850 { rep->set_parent (h); } |
|
851 |
|
852 bool is_hidden (void) const |
|
853 { return rep->is_hidden (); } |
|
854 |
|
855 void set_hidden (bool flag) |
|
856 { rep->set_hidden (flag); } |
|
857 |
|
858 octave_value get (void) const |
|
859 { return rep->get (); } |
|
860 |
|
861 void set (const octave_value& val) |
|
862 { rep->set (val); } |
|
863 |
|
864 property& operator = (const octave_value& val) |
|
865 { |
|
866 *rep = val; |
|
867 return *this; |
|
868 } |
|
869 |
|
870 property& operator = (const property& p) |
|
871 { |
|
872 if (rep && --rep->count <= 0) |
|
873 delete rep; |
|
874 |
|
875 rep = p.rep; |
|
876 rep->count++; |
|
877 |
|
878 return *this; |
|
879 } |
|
880 |
|
881 /* |
|
882 const string_property& as_string_property (void) const |
|
883 { return *(dynamic_cast<string_property*> (rep)); } |
|
884 |
|
885 const radio_property& as_radio_property (void) const |
|
886 { return *(dynamic_cast<radio_property*> (rep)); } |
|
887 |
|
888 const color_property& as_color_property (void) const |
|
889 { return *(dynamic_cast<color_property*> (rep)); } |
|
890 |
|
891 const double_property& as_double_property (void) const |
|
892 { return *(dynamic_cast<double_property*> (rep)); } |
|
893 |
|
894 const data_property& as_data_property (void) const |
|
895 { return *(dynamic_cast<data_property*> (rep)); } |
|
896 |
|
897 const bool_property& as_bool_property (void) const |
|
898 { return *(dynamic_cast<bool_property*> (rep)); } |
|
899 |
|
900 const handle_property& as_handle_property (void) const |
|
901 { return *(dynamic_cast<handle_property*> (rep)); } |
|
902 */ |
|
903 |
|
904 private: |
|
905 base_property *rep; |
|
906 }; |
|
907 |
|
908 // --------------------------------------------------------------------- |
|
909 |
|
910 class property_list |
|
911 { |
|
912 public: |
|
913 typedef std::map<std::string, octave_value> pval_map_type; |
|
914 typedef std::map<std::string, pval_map_type> plist_map_type; |
|
915 |
|
916 typedef pval_map_type::iterator pval_map_iterator; |
|
917 typedef pval_map_type::const_iterator pval_map_const_iterator; |
|
918 |
|
919 typedef plist_map_type::iterator plist_map_iterator; |
|
920 typedef plist_map_type::const_iterator plist_map_const_iterator; |
|
921 |
|
922 property_list (const plist_map_type& m = plist_map_type ()) |
|
923 : plist_map (m) { } |
|
924 |
|
925 ~property_list (void) { } |
|
926 |
|
927 void set (const caseless_str& name, const octave_value& val); |
|
928 |
|
929 octave_value lookup (const caseless_str& name) const; |
|
930 |
|
931 plist_map_iterator begin (void) { return plist_map.begin (); } |
|
932 plist_map_const_iterator begin (void) const { return plist_map.begin (); } |
|
933 |
|
934 plist_map_iterator end (void) { return plist_map.end (); } |
|
935 plist_map_const_iterator end (void) const { return plist_map.end (); } |
|
936 |
|
937 plist_map_iterator find (const std::string& go_name) |
|
938 { |
|
939 return plist_map.find (go_name); |
|
940 } |
|
941 |
|
942 plist_map_const_iterator find (const std::string& go_name) const |
|
943 { |
|
944 return plist_map.find (go_name); |
|
945 } |
|
946 |
|
947 Octave_map as_struct (const std::string& prefix_arg) const; |
|
948 |
|
949 private: |
|
950 plist_map_type plist_map; |
|
951 }; |
|
952 |
|
953 // --------------------------------------------------------------------- |
|
954 |
6874
|
955 class base_graphics_object; |
|
956 |
7365
|
957 class OCTINTERP_API base_properties |
6874
|
958 { |
|
959 public: |
7176
|
960 base_properties (const std::string& ty = "unknown", |
7363
|
961 const graphics_handle& mh = graphics_handle (), |
|
962 const graphics_handle& p = graphics_handle ()) |
|
963 : tag ("tag", mh), |
|
964 type ("type", mh, ty), |
|
965 __modified__ ("__modified__", mh, true), |
|
966 __myhandle__ (mh), |
7366
|
967 parent ("parent", mh, p), |
|
968 children (), |
|
969 busyaction ("parent", mh, "{queue}|cancel"), |
7367
|
970 buttondownfcn ("buttondownfcn", mh, Matrix ()), |
7366
|
971 clipping ("clipping", mh, true), |
7367
|
972 createfcn ("createfcn" , mh, Matrix ()), |
|
973 deletefcn ("deletefcn", mh, Matrix ()), |
7366
|
974 handlevisibility ("handlevisibility", mh, "{on}|callback|off"), |
|
975 hittest ("hittest", mh, true), |
|
976 interruptible ("interruptible", mh, true), |
|
977 selected ("selected", mh, false), |
|
978 selectionhighlight ("selectionhighlight", mh, true), |
|
979 uicontextmenu ("uicontextmenu", mh, graphics_handle ()), |
7367
|
980 userdata ("userdata", mh, Matrix ()), |
7366
|
981 visible ("visible", mh, true) |
7363
|
982 { } |
6874
|
983 |
|
984 virtual ~base_properties (void) { } |
|
985 |
|
986 virtual std::string graphics_object_name (void) const { return "unknonwn"; } |
|
987 |
|
988 void mark_modified (void); |
|
989 |
|
990 void override_defaults (base_graphics_object& obj); |
|
991 |
|
992 // Look through DEFAULTS for properties with given CLASS_NAME, and |
|
993 // apply them to the current object with set (virtual method). |
|
994 |
|
995 void set_from_list (base_graphics_object& obj, property_list& defaults); |
|
996 |
7363
|
997 void insert_property (const std::string& name, property p) |
|
998 { |
|
999 p.set_name (name); |
|
1000 p.set_parent (__myhandle__); |
|
1001 all_props[name] = p; |
|
1002 } |
|
1003 |
|
1004 virtual void set (const caseless_str&, const octave_value&); |
|
1005 |
|
1006 virtual octave_value get (const caseless_str&) const; |
|
1007 |
7379
|
1008 virtual octave_value get (bool all = false) const; |
7363
|
1009 |
|
1010 property get_property (const caseless_str&) const; |
|
1011 |
|
1012 std::string get_tag (void) const { return tag.string_value (); } |
|
1013 |
|
1014 graphics_handle get_parent (void) const { return parent.handle_value (); } |
|
1015 |
|
1016 std::string get_type (void) const { return type.string_value (); } |
|
1017 |
|
1018 bool is_modified (void) const { return __modified__.is_on (); } |
7251
|
1019 |
|
1020 graphics_handle get___myhandle__ (void) const { return __myhandle__; } |
7366
|
1021 |
|
1022 std::string get_busyaction (void) const { return busyaction.current_value (); } |
|
1023 |
|
1024 octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); } |
|
1025 |
|
1026 std::string get_clipping (void) const { return clipping.current_value (); } |
|
1027 |
7367
|
1028 void execute_createfcn (const octave_value& data = octave_value ()) const |
|
1029 { createfcn.execute (data); } |
|
1030 |
7366
|
1031 octave_value get_createfcn (void) const { return createfcn.get (); } |
|
1032 |
7367
|
1033 void execute_deletefcn (const octave_value& data = octave_value ()) const |
|
1034 { deletefcn.execute (data); } |
|
1035 |
7366
|
1036 octave_value get_deletefcn (void) const { return deletefcn.get (); } |
|
1037 |
|
1038 std::string get_handlevisibility (void) const { return handlevisibility.current_value (); } |
|
1039 |
|
1040 std::string get_hittest (void) const { return hittest.current_value (); } |
|
1041 |
|
1042 std::string get_interruptible (void) const { return interruptible.current_value (); } |
|
1043 |
|
1044 std::string get_selected (void) const { return selected.current_value (); } |
|
1045 |
|
1046 std::string get_selectionhighlight (void) const { return selectionhighlight.current_value (); } |
|
1047 |
|
1048 octave_value get_uicontextmenu (void) const { return uicontextmenu.get (); } |
|
1049 |
|
1050 octave_value get_userdata (void) const { return userdata.get (); } |
|
1051 |
|
1052 std::string get_visible (void) const { return visible.current_value (); } |
|
1053 |
6874
|
1054 void remove_child (const graphics_handle& h); |
|
1055 |
|
1056 void adopt (const graphics_handle& h) |
|
1057 { |
|
1058 octave_idx_type n = children.numel (); |
|
1059 children.resize (1, n+1); |
7056
|
1060 children(n) = h.value (); |
6874
|
1061 } |
|
1062 |
7363
|
1063 void set_tag (const octave_value& val) { tag = val; } |
7176
|
1064 |
6874
|
1065 void set_parent (const octave_value& val); |
|
1066 |
7366
|
1067 void set_busyaction (const octave_value& val) |
|
1068 { |
|
1069 if (! error_state) |
|
1070 { |
|
1071 busyaction = val; |
|
1072 mark_modified (); |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 void set_buttondownfcn (const octave_value& val) |
|
1077 { |
|
1078 if (! error_state) |
|
1079 { |
|
1080 buttondownfcn = val; |
|
1081 mark_modified (); |
|
1082 } |
|
1083 } |
|
1084 |
|
1085 void set_clipping (const octave_value& val) |
|
1086 { |
|
1087 if (! error_state) |
|
1088 { |
|
1089 clipping = val; |
|
1090 mark_modified (); |
|
1091 } |
|
1092 } |
|
1093 |
|
1094 void set_createfcn (const octave_value& val) |
|
1095 { |
|
1096 if (! error_state) |
|
1097 { |
|
1098 createfcn = val; |
|
1099 mark_modified (); |
|
1100 } |
|
1101 } |
|
1102 |
|
1103 void set_deletefcn (const octave_value& val) |
|
1104 { |
|
1105 if (! error_state) |
|
1106 { |
|
1107 deletefcn = val; |
|
1108 mark_modified (); |
|
1109 } |
|
1110 } |
|
1111 |
|
1112 void set_handlevisibility (const octave_value& val) |
|
1113 { |
|
1114 if (! error_state) |
|
1115 { |
|
1116 handlevisibility = val; |
|
1117 mark_modified (); |
|
1118 } |
|
1119 } |
|
1120 |
|
1121 void set_hittest (const octave_value& val) |
|
1122 { |
|
1123 if (! error_state) |
|
1124 { |
|
1125 hittest = val; |
|
1126 mark_modified (); |
|
1127 } |
|
1128 } |
|
1129 |
|
1130 void set_interruptible (const octave_value& val) |
|
1131 { |
|
1132 if (! error_state) |
|
1133 { |
|
1134 interruptible = val; |
|
1135 mark_modified (); |
|
1136 } |
|
1137 } |
|
1138 |
|
1139 void set_selected (const octave_value& val) |
|
1140 { |
|
1141 if (! error_state) |
|
1142 { |
|
1143 selected = val; |
|
1144 mark_modified (); |
|
1145 } |
|
1146 } |
|
1147 |
|
1148 void set_selectionhighlight (const octave_value& val) |
|
1149 { |
|
1150 if (! error_state) |
|
1151 { |
|
1152 selectionhighlight = val; |
|
1153 mark_modified (); |
|
1154 } |
|
1155 } |
|
1156 |
|
1157 void set_uicontextmenu (const octave_value& val) |
|
1158 { |
|
1159 if (! error_state) |
|
1160 { |
|
1161 uicontextmenu = val; |
|
1162 mark_modified (); |
|
1163 } |
|
1164 } |
|
1165 |
|
1166 void set_userdata (const octave_value& val) |
|
1167 { |
|
1168 if (! error_state) |
|
1169 { |
|
1170 userdata = val; |
|
1171 mark_modified (); |
|
1172 } |
|
1173 } |
|
1174 |
|
1175 virtual void set_visible (const octave_value& val) |
|
1176 { |
|
1177 if (! error_state) |
|
1178 { |
|
1179 visible = val; |
|
1180 mark_modified (); |
|
1181 } |
|
1182 } |
|
1183 |
|
1184 |
|
1185 |
6874
|
1186 void reparent (const graphics_handle& new_parent) { parent = new_parent; } |
|
1187 |
7214
|
1188 // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent |
|
1189 // axes object. |
|
1190 |
|
1191 void update_axis_limits (const std::string& axis_type) const; |
|
1192 |
6874
|
1193 virtual void delete_children (void); |
|
1194 |
7222
|
1195 Matrix get_children (void) const { return children; } |
|
1196 |
|
1197 // FIXME -- these functions should be generated automatically by the |
|
1198 // genprops.awk script. |
|
1199 // |
|
1200 // EMIT_BASE_PROPERTIES_GET_FUNCTIONS |
7363
|
1201 virtual data_property get_xdata_property (void) const |
7222
|
1202 { |
|
1203 error ("get: invalid property \"xdata\""); |
|
1204 return data_property (); |
|
1205 } |
|
1206 |
7363
|
1207 virtual data_property get_ydata_property (void) const |
7222
|
1208 { |
|
1209 error ("get: invalid property \"ydata\""); |
|
1210 return data_property (); |
|
1211 } |
|
1212 |
7363
|
1213 virtual data_property get_zdata_property (void) const |
7222
|
1214 { |
|
1215 error ("get: invalid property \"zdata\""); |
|
1216 return data_property (); |
|
1217 } |
|
1218 |
7363
|
1219 virtual data_property get_ldata_property (void) const |
7222
|
1220 { |
|
1221 error ("get: invalid property \"ldata\""); |
|
1222 return data_property (); |
|
1223 } |
|
1224 |
7363
|
1225 virtual data_property get_udata_property (void) const |
7222
|
1226 { |
|
1227 error ("get: invalid property \"udata\""); |
|
1228 return data_property (); |
|
1229 } |
|
1230 |
7363
|
1231 virtual data_property get_xldata_property (void) const |
7222
|
1232 { |
|
1233 error ("get: invalid property \"xldata\""); |
|
1234 return data_property (); |
|
1235 } |
|
1236 |
7363
|
1237 virtual data_property get_xudata_property (void) const |
7222
|
1238 { |
|
1239 error ("get: invalid property \"xudata\""); |
|
1240 return data_property (); |
|
1241 } |
|
1242 |
7363
|
1243 virtual data_property get_cdata_property (void) const |
7222
|
1244 { |
|
1245 error ("get: invalid property \"cdata\""); |
|
1246 return data_property (); |
|
1247 } |
|
1248 |
6874
|
1249 protected: |
7363
|
1250 string_property tag; |
|
1251 string_property type; |
|
1252 bool_property __modified__; |
6874
|
1253 graphics_handle __myhandle__; |
7363
|
1254 handle_property parent; |
|
1255 // FIXME: use a property class for children |
6874
|
1256 Matrix children; |
7366
|
1257 radio_property busyaction; |
|
1258 callback_property buttondownfcn; |
|
1259 bool_property clipping; |
|
1260 callback_property createfcn; |
|
1261 callback_property deletefcn; |
|
1262 radio_property handlevisibility; |
|
1263 bool_property hittest; |
|
1264 bool_property interruptible; |
|
1265 bool_property selected; |
|
1266 bool_property selectionhighlight; |
|
1267 handle_property uicontextmenu; |
|
1268 any_property userdata; |
|
1269 bool_property visible; |
7363
|
1270 |
|
1271 protected: |
|
1272 std::map<caseless_str, property> all_props; |
|
1273 |
|
1274 protected: |
|
1275 void insert_static_property (const std::string& name, base_property& p) |
|
1276 { insert_property (name, property (&p, true)); } |
|
1277 |
|
1278 virtual void init (void) { } |
6874
|
1279 }; |
|
1280 |
7365
|
1281 class OCTINTERP_API base_graphics_object |
6874
|
1282 { |
|
1283 public: |
|
1284 friend class graphics_object; |
|
1285 |
|
1286 base_graphics_object (void) : count (1) { } |
|
1287 |
|
1288 base_graphics_object (const base_graphics_object&) { } |
|
1289 |
|
1290 virtual ~base_graphics_object (void) { } |
|
1291 |
|
1292 virtual void mark_modified (void) |
|
1293 { |
|
1294 error ("base_graphics_object::mark_modified: invalid graphics object"); |
|
1295 } |
|
1296 |
|
1297 virtual void override_defaults (base_graphics_object&) |
|
1298 { |
|
1299 error ("base_graphics_object::override_defaults: invalid graphics object"); |
|
1300 } |
|
1301 |
|
1302 virtual void set_from_list (property_list&) |
|
1303 { |
|
1304 error ("base_graphics_object::set_from_list: invalid graphics object"); |
|
1305 } |
|
1306 |
7189
|
1307 virtual void set (const caseless_str&, const octave_value&) |
6874
|
1308 { |
|
1309 error ("base_graphics_object::set: invalid graphics object"); |
|
1310 } |
|
1311 |
|
1312 virtual void set_defaults (const std::string&) |
|
1313 { |
|
1314 error ("base_graphics_object::set_defaults: invalid graphics object"); |
|
1315 } |
|
1316 |
7379
|
1317 virtual octave_value get (bool all = false) const |
6874
|
1318 { |
|
1319 error ("base_graphics_object::get: invalid graphics object"); |
|
1320 return octave_value (); |
|
1321 } |
|
1322 |
7189
|
1323 virtual octave_value get (const caseless_str&) const |
6874
|
1324 { |
|
1325 error ("base_graphics_object::get: invalid graphics object"); |
|
1326 return octave_value (); |
|
1327 } |
|
1328 |
7189
|
1329 virtual octave_value get_default (const caseless_str&) const; |
6874
|
1330 |
7189
|
1331 virtual octave_value get_factory_default (const caseless_str&) const; |
6874
|
1332 |
|
1333 virtual octave_value get_defaults (void) const |
|
1334 { |
|
1335 error ("base_graphics_object::get_defaults: invalid graphics object"); |
|
1336 return octave_value (); |
|
1337 } |
|
1338 |
|
1339 virtual octave_value get_factory_defaults (void) const |
|
1340 { |
|
1341 error ("base_graphics_object::get_factory_defaults: invalid graphics object"); |
|
1342 return octave_value (); |
|
1343 } |
|
1344 |
|
1345 virtual graphics_handle get_parent (void) const |
|
1346 { |
|
1347 error ("base_graphics_object::get_parent: invalid graphics object"); |
|
1348 return graphics_handle (); |
|
1349 } |
|
1350 |
|
1351 virtual void remove_child (const graphics_handle&) |
|
1352 { |
|
1353 error ("base_graphics_object::remove_child: invalid graphics object"); |
|
1354 } |
|
1355 |
|
1356 virtual void adopt (const graphics_handle&) |
|
1357 { |
|
1358 error ("base_graphics_object::adopt: invalid graphics object"); |
|
1359 } |
|
1360 |
|
1361 virtual void reparent (const graphics_handle&) |
|
1362 { |
|
1363 error ("base_graphics_object::reparent: invalid graphics object"); |
|
1364 } |
|
1365 |
|
1366 virtual void defaults (void) const |
|
1367 { |
|
1368 error ("base_graphics_object::default: invalid graphics object"); |
|
1369 } |
|
1370 |
|
1371 virtual base_properties& get_properties (void) |
|
1372 { |
|
1373 static base_properties properties; |
|
1374 error ("base_graphics_object::get_properties: invalid graphics object"); |
|
1375 return properties; |
|
1376 } |
|
1377 |
7222
|
1378 virtual const base_properties& get_properties (void) const |
|
1379 { |
|
1380 static base_properties properties; |
|
1381 error ("base_graphics_object::get_properties: invalid graphics object"); |
|
1382 return properties; |
|
1383 } |
|
1384 |
|
1385 virtual void update_axis_limits (const std::string&) |
7214
|
1386 { |
|
1387 error ("base_graphics_object::update_axis_limits: invalid graphics object"); |
|
1388 } |
|
1389 |
6874
|
1390 virtual bool valid_object (void) const { return false; } |
|
1391 |
|
1392 virtual std::string type (void) const { return "unknown"; } |
|
1393 |
|
1394 bool isa (const std::string& go_name) const |
|
1395 { |
|
1396 return type () == go_name; |
|
1397 } |
|
1398 |
|
1399 protected: |
|
1400 // A reference count. |
|
1401 int count; |
|
1402 }; |
|
1403 |
7365
|
1404 class OCTINTERP_API graphics_object |
6874
|
1405 { |
|
1406 public: |
|
1407 graphics_object (void) : rep (new base_graphics_object ()) { } |
|
1408 |
|
1409 graphics_object (base_graphics_object *new_rep) |
|
1410 : rep (new_rep) { } |
|
1411 |
|
1412 graphics_object (const graphics_object& obj) |
|
1413 { |
|
1414 rep = obj.rep; |
|
1415 rep->count++; |
|
1416 } |
|
1417 |
|
1418 graphics_object& operator = (const graphics_object& obj) |
|
1419 { |
|
1420 if (rep != obj.rep) |
|
1421 { |
|
1422 if (--rep->count == 0) |
|
1423 delete rep; |
|
1424 |
|
1425 rep = obj.rep; |
|
1426 rep->count++; |
|
1427 } |
|
1428 |
|
1429 return *this; |
|
1430 } |
|
1431 |
|
1432 ~graphics_object (void) |
|
1433 { |
|
1434 if (--rep->count == 0) |
|
1435 delete rep; |
|
1436 } |
|
1437 |
|
1438 void mark_modified (void) { rep->mark_modified (); } |
|
1439 |
|
1440 void override_defaults (base_graphics_object& obj) |
|
1441 { |
|
1442 rep->override_defaults (obj); |
|
1443 } |
|
1444 |
7214
|
1445 void set_from_list (property_list& plist) { rep->set_from_list (plist); } |
6874
|
1446 |
7189
|
1447 void set (const caseless_str& name, const octave_value& val) |
6874
|
1448 { |
|
1449 rep->set (name, val); |
|
1450 } |
|
1451 |
|
1452 void set (const octave_value_list& args); |
|
1453 |
7214
|
1454 void set_defaults (const std::string& mode) { rep->set_defaults (mode); } |
|
1455 |
7379
|
1456 octave_value get (bool all = false) const { return rep->get (all); } |
6874
|
1457 |
7189
|
1458 octave_value get (const caseless_str& name) const |
6874
|
1459 { |
|
1460 return name.compare ("default") |
|
1461 ? get_defaults () |
|
1462 : (name.compare ("factory") |
|
1463 ? get_factory_defaults () : rep->get (name)); |
|
1464 } |
|
1465 |
7189
|
1466 octave_value get_default (const caseless_str& name) const |
6874
|
1467 { |
|
1468 return rep->get_default (name); |
|
1469 } |
|
1470 |
7189
|
1471 octave_value get_factory_default (const caseless_str& name) const |
6874
|
1472 { |
|
1473 return rep->get_factory_default (name); |
|
1474 } |
|
1475 |
|
1476 octave_value get_defaults (void) const { return rep->get_defaults (); } |
|
1477 |
|
1478 octave_value get_factory_defaults (void) const |
|
1479 { |
|
1480 return rep->get_factory_defaults (); |
|
1481 } |
|
1482 |
|
1483 graphics_handle get_parent (void) const { return rep->get_parent (); } |
|
1484 |
7214
|
1485 void remove_child (const graphics_handle& h) { rep->remove_child (h); } |
|
1486 |
|
1487 void adopt (const graphics_handle& h) { rep->adopt (h); } |
|
1488 |
|
1489 void reparent (const graphics_handle& h) { rep->reparent (h); } |
6874
|
1490 |
|
1491 void defaults (void) const { rep->defaults (); } |
|
1492 |
|
1493 bool isa (const std::string& go_name) const { return rep->isa (go_name); } |
|
1494 |
|
1495 base_properties& get_properties (void) { return rep->get_properties (); } |
|
1496 |
7222
|
1497 const base_properties& get_properties (void) const |
|
1498 { |
|
1499 return rep->get_properties (); |
|
1500 } |
|
1501 |
7214
|
1502 void update_axis_limits (const std::string& axis_type) |
|
1503 { |
|
1504 rep->update_axis_limits (axis_type); |
|
1505 } |
|
1506 |
6874
|
1507 bool valid_object (void) const { return rep->valid_object (); } |
|
1508 |
|
1509 operator bool (void) const { return rep->valid_object (); } |
|
1510 |
7222
|
1511 // FIXME -- these functions should be generated automatically by the |
|
1512 // genprops.awk script. |
|
1513 // |
|
1514 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS |
7363
|
1515 data_property get_xdata_property (void) const |
7222
|
1516 { |
|
1517 const base_properties& props = get_properties (); |
7363
|
1518 return props.get_xdata_property (); |
7222
|
1519 } |
|
1520 |
7363
|
1521 data_property get_ydata_property (void) const |
7222
|
1522 { |
|
1523 const base_properties& props = get_properties (); |
7363
|
1524 return props.get_ydata_property (); |
7222
|
1525 } |
|
1526 |
7363
|
1527 data_property get_zdata_property (void) const |
7222
|
1528 { |
|
1529 const base_properties& props = get_properties (); |
7363
|
1530 return props.get_zdata_property (); |
7222
|
1531 } |
|
1532 |
7363
|
1533 data_property get_ldata_property (void) const |
7222
|
1534 { |
|
1535 const base_properties& props = get_properties (); |
7363
|
1536 return props.get_ldata_property (); |
7222
|
1537 } |
|
1538 |
7363
|
1539 data_property get_udata_property (void) const |
7222
|
1540 { |
|
1541 const base_properties& props = get_properties (); |
7363
|
1542 return props.get_udata_property (); |
7222
|
1543 } |
|
1544 |
7363
|
1545 data_property get_xldata_property (void) const |
7222
|
1546 { |
|
1547 const base_properties& props = get_properties (); |
7363
|
1548 return props.get_xldata_property (); |
7222
|
1549 } |
|
1550 |
7363
|
1551 data_property get_xudata_property (void) const |
7222
|
1552 { |
|
1553 const base_properties& props = get_properties (); |
7363
|
1554 return props.get_xudata_property (); |
7222
|
1555 } |
|
1556 |
7363
|
1557 data_property get_cdata_property (void) const |
7222
|
1558 { |
|
1559 const base_properties& props = get_properties (); |
7363
|
1560 return props.get_cdata_property (); |
7222
|
1561 } |
|
1562 |
6874
|
1563 private: |
|
1564 base_graphics_object *rep; |
|
1565 }; |
|
1566 |
|
1567 // --------------------------------------------------------------------- |
|
1568 |
7365
|
1569 class OCTINTERP_API root_figure : public base_graphics_object |
6874
|
1570 { |
|
1571 public: |
|
1572 class properties : public base_properties |
|
1573 { |
|
1574 public: |
|
1575 // See the genprops.awk script for an explanation of the |
|
1576 // properties declarations. |
|
1577 |
7363
|
1578 BEGIN_PROPERTIES(root_figure) |
|
1579 handle_property currentfigure S , graphics_handle () |
6874
|
1580 END_PROPERTIES |
|
1581 }; |
|
1582 |
|
1583 private: |
|
1584 properties xproperties; |
|
1585 |
|
1586 public: |
|
1587 |
7363
|
1588 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { } |
6874
|
1589 |
|
1590 ~root_figure (void) { xproperties.delete_children (); } |
|
1591 |
|
1592 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
1593 |
|
1594 void mark_modified (void) { } |
|
1595 |
|
1596 void override_defaults (base_graphics_object& obj) |
|
1597 { |
|
1598 // Now override with our defaults. If the default_properties |
|
1599 // list includes the properties for all defaults (line, |
|
1600 // surface, etc.) then we don't have to know the type of OBJ |
|
1601 // here, we just call its set function and let it decide which |
|
1602 // properties from the list to use. |
|
1603 obj.set_from_list (default_properties); |
|
1604 } |
|
1605 |
|
1606 void set_from_list (property_list& plist) |
|
1607 { |
|
1608 xproperties.set_from_list (*this, plist); |
|
1609 } |
|
1610 |
7189
|
1611 void set (const caseless_str& name, const octave_value& value) |
6874
|
1612 { |
|
1613 if (name.compare ("default", 7)) |
|
1614 // strip "default", pass rest to function that will |
|
1615 // parse the remainder and add the element to the |
|
1616 // default_properties map. |
|
1617 default_properties.set (name.substr (7), value); |
|
1618 else |
|
1619 xproperties.set (name, value); |
|
1620 } |
|
1621 |
7379
|
1622 octave_value get (bool all = false) const |
6874
|
1623 { |
7379
|
1624 return xproperties.get (all); |
6874
|
1625 } |
|
1626 |
7189
|
1627 octave_value get (const caseless_str& name) const |
6874
|
1628 { |
|
1629 octave_value retval; |
|
1630 |
|
1631 if (name.compare ("default", 7)) |
|
1632 return get_default (name.substr (7)); |
|
1633 else if (name.compare ("factory", 7)) |
|
1634 return get_factory_default (name.substr (7)); |
|
1635 else |
|
1636 retval = xproperties.get (name); |
|
1637 |
|
1638 return retval; |
|
1639 } |
|
1640 |
7189
|
1641 octave_value get_default (const caseless_str& name) const |
6874
|
1642 { |
|
1643 octave_value retval = default_properties.lookup (name); |
|
1644 |
|
1645 if (retval.is_undefined ()) |
|
1646 error ("get: invalid default property `%s'", name.c_str ()); |
|
1647 |
|
1648 return retval; |
|
1649 } |
|
1650 |
7189
|
1651 octave_value get_factory_default (const caseless_str& name) const |
6874
|
1652 { |
|
1653 octave_value retval = factory_properties.lookup (name); |
|
1654 |
|
1655 if (retval.is_undefined ()) |
|
1656 error ("get: invalid factory default property `%s'", name.c_str ()); |
|
1657 |
|
1658 return retval; |
|
1659 } |
|
1660 |
|
1661 octave_value get_defaults (void) const |
|
1662 { |
|
1663 return default_properties.as_struct ("default"); |
|
1664 } |
|
1665 |
|
1666 octave_value get_factory_defaults (void) const |
|
1667 { |
|
1668 return factory_properties.as_struct ("factory"); |
|
1669 } |
|
1670 |
|
1671 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
1672 |
|
1673 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
1674 |
|
1675 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
1676 |
|
1677 void reparent (const graphics_handle& np) { xproperties.reparent (np); } |
|
1678 |
|
1679 base_properties& get_properties (void) { return xproperties; } |
|
1680 |
7222
|
1681 const base_properties& get_properties (void) const { return xproperties; } |
|
1682 |
6890
|
1683 void defaults (void) const |
|
1684 { |
|
1685 gripe_not_implemented ("root_figure::defaults"); |
|
1686 } |
|
1687 |
6874
|
1688 bool valid_object (void) const { return true; } |
|
1689 |
|
1690 private: |
|
1691 property_list default_properties; |
|
1692 |
|
1693 static property_list factory_properties; |
|
1694 |
|
1695 static property_list::plist_map_type init_factory_properties (void); |
|
1696 }; |
|
1697 |
|
1698 // --------------------------------------------------------------------- |
|
1699 |
7365
|
1700 class OCTINTERP_API figure : public base_graphics_object |
6874
|
1701 { |
|
1702 public: |
|
1703 class properties : public base_properties |
|
1704 { |
|
1705 public: |
|
1706 void close (void); |
7366
|
1707 void set_visible (const octave_value& val); |
6874
|
1708 |
|
1709 // See the genprops.awk script for an explanation of the |
|
1710 // properties declarations. |
|
1711 |
7363
|
1712 BEGIN_PROPERTIES(figure) |
7379
|
1713 any_property __plot_stream__ h , Matrix () |
|
1714 bool_property __enhanced__ h , "on" |
7363
|
1715 radio_property nextplot , "add|replace_children|{replace}" |
|
1716 callback_property closerequestfcn , "closereq" |
|
1717 handle_property currentaxes S , graphics_handle () |
|
1718 array_property colormap , jet_colormap () |
|
1719 radio_property paperorientation , "{portrait}|landscape" |
|
1720 color_property color , color_values (1, 1, 1) |
6874
|
1721 END_PROPERTIES |
7363
|
1722 |
|
1723 protected: |
|
1724 void init (void) |
|
1725 { |
|
1726 colormap.add_constraint (dim_vector (-1, 3)); |
|
1727 } |
6874
|
1728 }; |
|
1729 |
|
1730 private: |
|
1731 properties xproperties; |
|
1732 |
|
1733 public: |
|
1734 figure (const graphics_handle& mh, const graphics_handle& p) |
|
1735 : base_graphics_object (), xproperties (mh, p), default_properties () |
|
1736 { |
|
1737 xproperties.override_defaults (*this); |
|
1738 } |
|
1739 |
|
1740 ~figure (void) |
|
1741 { |
|
1742 xproperties.delete_children (); |
|
1743 xproperties.close (); |
|
1744 } |
|
1745 |
|
1746 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
1747 |
|
1748 void mark_modified (void) { xproperties.mark_modified (); } |
|
1749 |
|
1750 void override_defaults (base_graphics_object& obj) |
|
1751 { |
|
1752 // Allow parent (root figure) to override first (properties knows how |
|
1753 // to find the parent object). |
|
1754 xproperties.override_defaults (obj); |
|
1755 |
|
1756 // Now override with our defaults. If the default_properties |
|
1757 // list includes the properties for all defaults (line, |
|
1758 // surface, etc.) then we don't have to know the type of OBJ |
|
1759 // here, we just call its set function and let it decide which |
|
1760 // properties from the list to use. |
|
1761 obj.set_from_list (default_properties); |
|
1762 } |
|
1763 |
|
1764 void set_from_list (property_list& plist) |
|
1765 { |
|
1766 xproperties.set_from_list (*this, plist); |
|
1767 } |
|
1768 |
7189
|
1769 void set (const caseless_str& name, const octave_value& value) |
6874
|
1770 { |
|
1771 if (name.compare ("default", 7)) |
|
1772 // strip "default", pass rest to function that will |
|
1773 // parse the remainder and add the element to the |
|
1774 // default_properties map. |
|
1775 default_properties.set (name.substr (7), value); |
|
1776 else |
|
1777 xproperties.set (name, value); |
|
1778 } |
|
1779 |
7379
|
1780 octave_value get (bool all = false) const |
6874
|
1781 { |
7379
|
1782 return xproperties.get (all); |
6874
|
1783 } |
|
1784 |
7189
|
1785 octave_value get (const caseless_str& name) const |
6874
|
1786 { |
|
1787 octave_value retval; |
|
1788 |
|
1789 if (name.compare ("default", 7)) |
|
1790 retval = get_default (name.substr (7)); |
|
1791 else |
|
1792 retval = xproperties.get (name); |
|
1793 |
|
1794 return retval; |
|
1795 } |
|
1796 |
7189
|
1797 octave_value get_default (const caseless_str& name) const; |
6874
|
1798 |
|
1799 octave_value get_defaults (void) const |
|
1800 { |
|
1801 return default_properties.as_struct ("default"); |
|
1802 } |
|
1803 |
|
1804 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
1805 |
|
1806 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
1807 |
|
1808 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
1809 |
|
1810 void reparent (const graphics_handle& np) { xproperties.reparent (np); } |
|
1811 |
|
1812 base_properties& get_properties (void) { return xproperties; } |
|
1813 |
7222
|
1814 const base_properties& get_properties (void) const { return xproperties; } |
|
1815 |
6890
|
1816 void defaults (void) const { gripe_not_implemented ("figure::defaults"); } |
|
1817 |
6874
|
1818 bool valid_object (void) const { return true; } |
|
1819 |
|
1820 private: |
|
1821 property_list default_properties; |
|
1822 }; |
|
1823 |
|
1824 // --------------------------------------------------------------------- |
|
1825 |
7365
|
1826 class OCTINTERP_API axes : public base_graphics_object |
6874
|
1827 { |
|
1828 public: |
|
1829 class properties : public base_properties |
|
1830 { |
|
1831 public: |
|
1832 void set_defaults (base_graphics_object& obj, const std::string& mode); |
|
1833 |
|
1834 void remove_child (const graphics_handle& h); |
|
1835 |
|
1836 void delete_children (void); |
|
1837 |
|
1838 // See the genprops.awk script for an explanation of the |
|
1839 // properties declarations. |
|
1840 |
7363
|
1841 BEGIN_PROPERTIES(axes) |
|
1842 array_property position , Matrix () |
|
1843 mutable handle_property title GSO , graphics_handle () |
|
1844 bool_property box , "on" |
|
1845 bool_property key , "off" |
|
1846 bool_property keybox , "off" |
|
1847 double_property keypos , 1 |
|
1848 array_property colororder , default_colororder () |
|
1849 array_property dataaspectratio m , Matrix (1, 3, 1.0) |
|
1850 radio_property dataaspectratiomode , "{auto}|manual" |
7379
|
1851 radio_property layer , "{bottom}|top" |
7363
|
1852 array_property xlim m , default_lim () |
|
1853 array_property ylim m , default_lim () |
|
1854 array_property zlim m , default_lim () |
|
1855 array_property clim m , default_lim () |
|
1856 radio_property xlimmode al , "{auto}|manual" |
|
1857 radio_property ylimmode al , "{auto}|manual" |
|
1858 radio_property zlimmode al , "{auto}|manual" |
|
1859 radio_property climmode al , "{auto}|manual" |
|
1860 mutable handle_property xlabel GSO , graphics_handle () |
|
1861 mutable handle_property ylabel GSO , graphics_handle () |
|
1862 mutable handle_property zlabel GSO , graphics_handle () |
|
1863 bool_property xgrid , "off" |
|
1864 bool_property ygrid , "off" |
|
1865 bool_property zgrid , "off" |
|
1866 bool_property xminorgrid , "off" |
|
1867 bool_property yminorgrid , "off" |
|
1868 bool_property zminorgrid , "off" |
|
1869 array_property xtick m , Matrix () |
|
1870 array_property ytick m , Matrix () |
|
1871 array_property ztick m , Matrix () |
|
1872 radio_property xtickmode , "{auto}|manual" |
|
1873 radio_property ytickmode , "{auto}|manual" |
|
1874 radio_property ztickmode , "{auto}|manual" |
|
1875 any_property xticklabel m , "" |
|
1876 any_property yticklabel m , "" |
|
1877 any_property zticklabel m , "" |
|
1878 radio_property xticklabelmode , "{auto}|manual" |
|
1879 radio_property yticklabelmode , "{auto}|manual" |
|
1880 radio_property zticklabelmode , "{auto}|manual" |
7379
|
1881 color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) |
7363
|
1882 color_property xcolor , color_values (0, 0, 0) |
|
1883 color_property ycolor , color_values (0, 0, 0) |
|
1884 color_property zcolor , color_values (0, 0, 0) |
|
1885 radio_property xscale al , "{linear}|log" |
|
1886 radio_property yscale al , "{linear}|log" |
|
1887 radio_property zscale al , "{linear}|log" |
|
1888 radio_property xdir , "{normal}|reverse" |
|
1889 radio_property ydir , "{normal}|reverse" |
|
1890 radio_property zdir , "{normal}|reverse" |
7365
|
1891 radio_property yaxislocation , "{left}|right|zero" |
|
1892 radio_property xaxislocation , "{bottom}|top|zero" |
7363
|
1893 array_property view , Matrix () |
|
1894 radio_property nextplot , "add|replace_children|{replace}" |
|
1895 array_property outerposition , Matrix () |
7379
|
1896 radio_property activepositionproperty , "{outerposition}|position" |
|
1897 radio_property __colorbar__ h , "{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside" |
7189
|
1898 END_PROPERTIES |
6874
|
1899 |
7363
|
1900 protected: |
|
1901 void init (void) |
|
1902 { |
|
1903 position.add_constraint (dim_vector (1, 4)); |
|
1904 position.add_constraint (dim_vector (0, 0)); |
|
1905 outerposition.add_constraint (dim_vector (1, 4)); |
|
1906 colororder.add_constraint (dim_vector (-1, 3)); |
|
1907 dataaspectratio.add_constraint (dim_vector (1, 3)); |
|
1908 xlim.add_constraint (dim_vector (1, 2)); |
|
1909 ylim.add_constraint (dim_vector (1, 2)); |
|
1910 zlim.add_constraint (dim_vector (1, 2)); |
|
1911 clim.add_constraint (dim_vector (1, 2)); |
|
1912 xtick.add_constraint (dim_vector (1, -1)); |
|
1913 ytick.add_constraint (dim_vector (1, -1)); |
|
1914 ztick.add_constraint (dim_vector (1, -1)); |
|
1915 Matrix vw (1, 2, 0); |
|
1916 vw(1) = 90; |
|
1917 view = vw; |
|
1918 view.add_constraint (dim_vector (1, 2)); |
|
1919 } |
6874
|
1920 }; |
|
1921 |
|
1922 private: |
|
1923 properties xproperties; |
|
1924 |
|
1925 public: |
|
1926 axes (const graphics_handle& mh, const graphics_handle& p) |
|
1927 : base_graphics_object (), xproperties (mh, p), default_properties () |
|
1928 { |
|
1929 xproperties.override_defaults (*this); |
|
1930 } |
|
1931 |
|
1932 ~axes (void) { xproperties.delete_children (); } |
|
1933 |
|
1934 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
1935 |
|
1936 void mark_modified (void) { xproperties.mark_modified (); } |
|
1937 |
|
1938 void override_defaults (base_graphics_object& obj) |
|
1939 { |
|
1940 // Allow parent (figure) to override first (properties knows how |
|
1941 // to find the parent object). |
|
1942 xproperties.override_defaults (obj); |
|
1943 |
|
1944 // Now override with our defaults. If the default_properties |
|
1945 // list includes the properties for all defaults (line, |
|
1946 // surface, etc.) then we don't have to know the type of OBJ |
|
1947 // here, we just call its set function and let it decide which |
|
1948 // properties from the list to use. |
|
1949 obj.set_from_list (default_properties); |
|
1950 } |
|
1951 |
|
1952 void set_from_list (property_list& plist) |
|
1953 { |
|
1954 xproperties.set_from_list (*this, plist); |
|
1955 } |
|
1956 |
7189
|
1957 void set (const caseless_str& name, const octave_value& value) |
6874
|
1958 { |
|
1959 if (name.compare ("default", 7)) |
|
1960 // strip "default", pass rest to function that will |
|
1961 // parse the remainder and add the element to the |
|
1962 // default_properties map. |
|
1963 default_properties.set (name.substr (7), value); |
|
1964 else |
|
1965 xproperties.set (name, value); |
|
1966 } |
|
1967 |
|
1968 void set_defaults (const std::string& mode) |
|
1969 { |
|
1970 xproperties.set_defaults (*this, mode); |
|
1971 } |
|
1972 |
7379
|
1973 octave_value get (bool all = false) const |
6874
|
1974 { |
7379
|
1975 return xproperties.get (all); |
6874
|
1976 } |
|
1977 |
7189
|
1978 octave_value get (const caseless_str& name) const |
6874
|
1979 { |
|
1980 octave_value retval; |
|
1981 |
|
1982 // FIXME -- finish this. |
|
1983 if (name.compare ("default", 7)) |
|
1984 retval = get_default (name.substr (7)); |
|
1985 else |
|
1986 retval = xproperties.get (name); |
|
1987 |
|
1988 return retval; |
|
1989 } |
|
1990 |
7189
|
1991 octave_value get_default (const caseless_str& name) const; |
6874
|
1992 |
|
1993 octave_value get_defaults (void) const |
|
1994 { |
|
1995 return default_properties.as_struct ("default"); |
|
1996 } |
|
1997 |
|
1998 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
1999 |
|
2000 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2001 |
|
2002 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2003 |
|
2004 void reparent (const graphics_handle& np) { xproperties.reparent (np); } |
|
2005 |
|
2006 base_properties& get_properties (void) { return xproperties; } |
|
2007 |
7222
|
2008 const base_properties& get_properties (void) const { return xproperties; } |
|
2009 |
6890
|
2010 void defaults (void) const { gripe_not_implemented ("axes::defaults"); } |
|
2011 |
7214
|
2012 void update_axis_limits (const std::string& axis_type); |
|
2013 |
6874
|
2014 bool valid_object (void) const { return true; } |
|
2015 |
|
2016 private: |
|
2017 property_list default_properties; |
|
2018 }; |
|
2019 |
|
2020 // --------------------------------------------------------------------- |
|
2021 |
7365
|
2022 class OCTINTERP_API line : public base_graphics_object |
6874
|
2023 { |
|
2024 public: |
|
2025 class properties : public base_properties |
|
2026 { |
|
2027 public: |
|
2028 // See the genprops.awk script for an explanation of the |
|
2029 // properties declarations. |
|
2030 |
7366
|
2031 // properties which are not in matlab: |
|
2032 // ldata, udata, xldata, xudata, keylabel, interpreter |
|
2033 |
7363
|
2034 BEGIN_PROPERTIES(line) |
|
2035 data_property xdata l , default_data () |
|
2036 data_property ydata l , default_data () |
|
2037 data_property zdata l , Matrix () |
|
2038 data_property ldata l , Matrix () |
|
2039 data_property udata l , Matrix () |
|
2040 data_property xldata l , Matrix () |
|
2041 data_property xudata l , Matrix () |
|
2042 color_property color , color_values (0, 0, 0) |
|
2043 radio_property linestyle , "{-}|--|:|-.|none" |
|
2044 double_property linewidth , 0.5 |
|
2045 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" |
|
2046 color_property markeredgecolor , "{auto}|none" |
|
2047 color_property markerfacecolor , "auto|{none}" |
|
2048 double_property markersize , 6 |
|
2049 string_property keylabel , "" |
7379
|
2050 radio_property interpreter , "{tex}|none|latex" |
7377
|
2051 string_property displayname , "" |
|
2052 radio_property erase_mode , "{normal}|none|xor|background" |
6874
|
2053 END_PROPERTIES |
|
2054 }; |
|
2055 |
|
2056 private: |
|
2057 properties xproperties; |
|
2058 |
|
2059 public: |
|
2060 line (const graphics_handle& mh, const graphics_handle& p) |
|
2061 : base_graphics_object (), xproperties (mh, p) |
|
2062 { |
|
2063 xproperties.override_defaults (*this); |
|
2064 } |
|
2065 |
|
2066 ~line (void) { xproperties.delete_children (); } |
|
2067 |
|
2068 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
2069 |
|
2070 void mark_modified (void) { xproperties.mark_modified (); } |
|
2071 |
|
2072 void override_defaults (base_graphics_object& obj) |
|
2073 { |
|
2074 // Allow parent (figure) to override first (properties knows how |
|
2075 // to find the parent object). |
|
2076 xproperties.override_defaults (obj); |
|
2077 } |
|
2078 |
|
2079 void set_from_list (property_list& plist) |
|
2080 { |
|
2081 xproperties.set_from_list (*this, plist); |
|
2082 } |
|
2083 |
7189
|
2084 void set (const caseless_str& name, const octave_value& val) |
6874
|
2085 { |
|
2086 xproperties.set (name, val); |
|
2087 } |
|
2088 |
7379
|
2089 octave_value get (bool all = false) const |
6874
|
2090 { |
7379
|
2091 return xproperties.get (all); |
6874
|
2092 } |
|
2093 |
7189
|
2094 octave_value get (const caseless_str& name) const |
6874
|
2095 { |
|
2096 return xproperties.get (name); |
|
2097 } |
|
2098 |
|
2099 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
2100 |
|
2101 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2102 |
|
2103 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2104 |
|
2105 void reparent (const graphics_handle& h) { xproperties.reparent (h); } |
|
2106 |
|
2107 base_properties& get_properties (void) { return xproperties; } |
|
2108 |
7222
|
2109 const base_properties& get_properties (void) const { return xproperties; } |
|
2110 |
6890
|
2111 void defaults (void) const { gripe_not_implemented ("line::defaults"); } |
|
2112 |
6874
|
2113 bool valid_object (void) const { return true; } |
|
2114 }; |
|
2115 |
|
2116 // --------------------------------------------------------------------- |
|
2117 |
7365
|
2118 class OCTINTERP_API text : public base_graphics_object |
6874
|
2119 { |
|
2120 public: |
|
2121 class properties : public base_properties |
|
2122 { |
|
2123 public: |
|
2124 // See the genprops.awk script for an explanation of the |
|
2125 // properties declarations. |
|
2126 |
7363
|
2127 BEGIN_PROPERTIES(text) |
|
2128 string_property string , "" |
|
2129 radio_property units , "{data}|pixels|normalized|inches|centimeters|points" |
|
2130 array_property position , Matrix (1, 3, 0.0) |
|
2131 double_property rotation , 0 |
|
2132 radio_property horizontalalignment , "{left}|center|right" |
|
2133 color_property color , color_values (0, 0, 0) |
|
2134 string_property fontname , "Helvetica" |
|
2135 double_property fontsize , 10 |
7379
|
2136 radio_property fontangle , "{normal}|italic|oblique" |
|
2137 radio_property fontweight , "light|{normal}|demi|bold" |
|
2138 radio_property interpreter , "{tex}|none|latex" |
7377
|
2139 color_property backgroundcolor , "{none}" |
|
2140 string_property displayname , "" |
|
2141 color_property edgecolor , "{none}" |
|
2142 radio_property erase_mode , "{normal}|none|xor|background" |
|
2143 bool_property editing , "off" |
|
2144 radio_property fontunits , "inches|centimeters|normalized|{points}|pixel" |
|
2145 radio_property linestyle , "{-}|--|:|-.|none" |
|
2146 double_property linewidth , 0.5 |
|
2147 double_property margin , 1 |
|
2148 radio_property verticalalignment , "top|cap|{middle}|baseline|bottom" |
6874
|
2149 END_PROPERTIES |
|
2150 |
7363
|
2151 protected: |
|
2152 void init (void) |
|
2153 { |
|
2154 position.add_constraint (dim_vector (1, 3)); |
|
2155 } |
6874
|
2156 }; |
|
2157 |
|
2158 private: |
|
2159 properties xproperties; |
|
2160 |
|
2161 public: |
|
2162 text (const graphics_handle& mh, const graphics_handle& p) |
|
2163 : base_graphics_object (), xproperties (mh, p) |
|
2164 { |
|
2165 xproperties.override_defaults (*this); |
|
2166 } |
|
2167 |
|
2168 ~text (void) { xproperties.delete_children (); } |
|
2169 |
|
2170 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
2171 |
|
2172 void mark_modified (void) { xproperties.mark_modified (); } |
|
2173 |
|
2174 void override_defaults (base_graphics_object& obj) |
|
2175 { |
|
2176 // Allow parent (figure) to override first (properties knows how |
|
2177 // to find the parent object). |
|
2178 xproperties.override_defaults (obj); |
|
2179 } |
|
2180 |
|
2181 void set_from_list (property_list& plist) |
|
2182 { |
|
2183 xproperties.set_from_list (*this, plist); |
|
2184 } |
|
2185 |
7189
|
2186 void set (const caseless_str& name, const octave_value& val) |
6874
|
2187 { |
|
2188 xproperties.set (name, val); |
|
2189 } |
|
2190 |
7379
|
2191 octave_value get (bool all = false) const |
6874
|
2192 { |
7379
|
2193 return xproperties.get (all); |
6874
|
2194 } |
|
2195 |
7189
|
2196 octave_value get (const caseless_str& name) const |
6874
|
2197 { |
|
2198 return xproperties.get (name); |
|
2199 } |
|
2200 |
|
2201 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
2202 |
|
2203 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2204 |
|
2205 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2206 |
|
2207 void reparent (const graphics_handle& h) { xproperties.reparent (h); } |
|
2208 |
|
2209 base_properties& get_properties (void) { return xproperties; } |
|
2210 |
7222
|
2211 const base_properties& get_properties (void) const { return xproperties; } |
|
2212 |
6890
|
2213 void defaults (void) const { gripe_not_implemented ("text::defaults"); } |
|
2214 |
6874
|
2215 bool valid_object (void) const { return true; } |
|
2216 }; |
|
2217 |
|
2218 // --------------------------------------------------------------------- |
|
2219 |
7365
|
2220 class OCTINTERP_API image : public base_graphics_object |
6874
|
2221 { |
|
2222 public: |
|
2223 class properties : public base_properties |
|
2224 { |
|
2225 public: |
|
2226 // See the genprops.awk script for an explanation of the |
|
2227 // properties declarations. |
|
2228 |
7363
|
2229 BEGIN_PROPERTIES(image) |
|
2230 data_property xdata l , Matrix () |
|
2231 data_property ydata l , Matrix () |
|
2232 data_property cdata l , Matrix () |
6874
|
2233 END_PROPERTIES |
|
2234 |
7363
|
2235 protected: |
|
2236 void init (void) |
|
2237 { |
|
2238 } |
6874
|
2239 }; |
|
2240 |
|
2241 private: |
|
2242 properties xproperties; |
|
2243 |
|
2244 public: |
|
2245 image (const graphics_handle& mh, const graphics_handle& p) |
|
2246 : base_graphics_object (), xproperties (mh, p) |
|
2247 { |
|
2248 xproperties.override_defaults (*this); |
|
2249 } |
|
2250 |
|
2251 ~image (void) { xproperties.delete_children (); } |
|
2252 |
|
2253 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
2254 |
|
2255 void mark_modified (void) { xproperties.mark_modified (); } |
|
2256 |
|
2257 void override_defaults (base_graphics_object& obj) |
|
2258 { |
|
2259 // Allow parent (figure) to override first (properties knows how |
|
2260 // to find the parent object). |
|
2261 xproperties.override_defaults (obj); |
|
2262 } |
|
2263 |
|
2264 void set_from_list (property_list& plist) |
|
2265 { |
|
2266 xproperties.set_from_list (*this, plist); |
|
2267 } |
|
2268 |
7189
|
2269 void set (const caseless_str& name, const octave_value& val) |
6874
|
2270 { |
|
2271 xproperties.set (name, val); |
|
2272 } |
|
2273 |
7379
|
2274 octave_value get (bool all = false) const |
6874
|
2275 { |
7379
|
2276 return xproperties.get (all); |
6874
|
2277 } |
|
2278 |
7189
|
2279 octave_value get (const caseless_str& name) const |
6874
|
2280 { |
|
2281 return xproperties.get (name); |
|
2282 } |
|
2283 |
|
2284 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
2285 |
|
2286 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2287 |
|
2288 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2289 |
|
2290 void reparent (const graphics_handle& h) { xproperties.reparent (h); } |
|
2291 |
|
2292 base_properties& get_properties (void) { return xproperties; } |
|
2293 |
7222
|
2294 const base_properties& get_properties (void) const { return xproperties; } |
|
2295 |
6890
|
2296 void defaults (void) const { gripe_not_implemented ("image::defaults"); } |
|
2297 |
6874
|
2298 bool valid_object (void) const { return true; } |
|
2299 }; |
|
2300 |
|
2301 // --------------------------------------------------------------------- |
|
2302 |
7365
|
2303 class OCTINTERP_API patch : public base_graphics_object |
6874
|
2304 { |
|
2305 public: |
|
2306 class properties : public base_properties |
|
2307 { |
|
2308 public: |
|
2309 // See the genprops.awk script for an explanation of the |
|
2310 // properties declarations. |
|
2311 |
7363
|
2312 BEGIN_PROPERTIES(patch) |
7368
|
2313 data_property xdata l , Matrix () |
7363
|
2314 data_property ydata l , Matrix () |
|
2315 data_property zdata l , Matrix () |
|
2316 data_property cdata l , Matrix () |
7379
|
2317 radio_property cdatamapping , "{scaled}|direct" |
7363
|
2318 array_property faces , Matrix () |
7368
|
2319 data_property facevertexalphadata , Matrix () |
|
2320 data_property facevertexcdata , Matrix () |
7363
|
2321 array_property vertices , Matrix () |
7368
|
2322 array_property vertexnormals , Matrix () |
7379
|
2323 radio_property normalmode , "{auto}|manual" |
|
2324 color_property facecolor , "{flat}|none|interp" |
7363
|
2325 double_property facealpha , 1.0 |
7379
|
2326 radio_property facelighting , "{flat}|none|gouraud|phong" |
|
2327 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7368
|
2328 double_property edgealpha , 1.0 |
7379
|
2329 radio_property edgelighting , "{none}|flat|gouraud|phong" |
|
2330 radio_property backfacelighting , "{reverselit}|unlit|lit" |
7368
|
2331 double_property ambientstrength , 0.3 |
|
2332 double_property diffusestrength , 0.6 |
|
2333 double_property specularstrength , 0.6 |
|
2334 double_property specularexponent , 10.0 |
|
2335 double_property specularcolorreflectance , 1.0 |
7379
|
2336 radio_property erasemode , "{normal}|background|xor|none" |
7363
|
2337 radio_property linestyle , "{-}|--|:|-.|none" |
|
2338 double_property linewidth , 0.5 |
|
2339 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" |
|
2340 color_property markeredgecolor , "{auto}|none" |
|
2341 color_property markerfacecolor , "auto|{none}" |
|
2342 double_property markersize , 6 |
|
2343 string_property keylabel , "" |
7379
|
2344 radio_property interpreter , "{tex}|none|latex" |
6874
|
2345 END_PROPERTIES |
|
2346 |
7363
|
2347 protected: |
|
2348 void init (void) |
|
2349 { |
|
2350 vertices.add_constraint (dim_vector (-1, 2)); |
|
2351 vertices.add_constraint (dim_vector (-1, 3)); |
|
2352 } |
6874
|
2353 }; |
|
2354 |
|
2355 private: |
|
2356 properties xproperties; |
|
2357 |
|
2358 public: |
|
2359 patch (const graphics_handle& mh, const graphics_handle& p) |
|
2360 : base_graphics_object (), xproperties (mh, p) |
|
2361 { |
|
2362 xproperties.override_defaults (*this); |
|
2363 } |
|
2364 |
|
2365 ~patch (void) { xproperties.delete_children (); } |
|
2366 |
|
2367 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
2368 |
|
2369 void mark_modified (void) { xproperties.mark_modified (); } |
|
2370 |
|
2371 void override_defaults (base_graphics_object& obj) |
|
2372 { |
|
2373 // Allow parent (figure) to override first (properties knows how |
|
2374 // to find the parent object). |
|
2375 xproperties.override_defaults (obj); |
|
2376 } |
|
2377 |
|
2378 void set_from_list (property_list& plist) |
|
2379 { |
|
2380 xproperties.set_from_list (*this, plist); |
|
2381 } |
|
2382 |
7189
|
2383 void set (const caseless_str& name, const octave_value& val) |
6874
|
2384 { |
|
2385 xproperties.set (name, val); |
|
2386 } |
|
2387 |
7379
|
2388 octave_value get (bool all = false) const |
6874
|
2389 { |
7379
|
2390 return xproperties.get (all); |
6874
|
2391 } |
|
2392 |
7189
|
2393 octave_value get (const caseless_str& name) const |
6874
|
2394 { |
|
2395 return xproperties.get (name); |
|
2396 } |
|
2397 |
|
2398 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
2399 |
|
2400 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2401 |
|
2402 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2403 |
|
2404 void reparent (const graphics_handle& h) { xproperties.reparent (h); } |
|
2405 |
|
2406 base_properties& get_properties (void) { return xproperties; } |
|
2407 |
7222
|
2408 const base_properties& get_properties (void) const { return xproperties; } |
|
2409 |
6890
|
2410 void defaults (void) const { gripe_not_implemented ("patch::defaults"); } |
|
2411 |
6874
|
2412 bool valid_object (void) const { return true; } |
|
2413 }; |
|
2414 |
|
2415 // --------------------------------------------------------------------- |
|
2416 |
7365
|
2417 class OCTINTERP_API surface : public base_graphics_object |
6874
|
2418 { |
|
2419 public: |
|
2420 class properties : public base_properties |
|
2421 { |
|
2422 public: |
|
2423 // See the genprops.awk script for an explanation of the |
|
2424 // properties declarations. |
|
2425 |
7363
|
2426 BEGIN_PROPERTIES(surface) |
|
2427 data_property xdata l , Matrix () |
|
2428 data_property ydata l , Matrix () |
|
2429 data_property zdata l , Matrix () |
|
2430 data_property cdata l , Matrix () |
7379
|
2431 color_property facecolor , "{flat}|none|interp" |
7363
|
2432 double_property facealpha , 1.0 |
7379
|
2433 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7363
|
2434 radio_property linestyle , "{-}|--|:|-.|none" |
|
2435 double_property linewidth , 0.5 |
|
2436 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" |
|
2437 color_property markeredgecolor , "{auto}|none" |
|
2438 color_property markerfacecolor , "auto|{none}" |
|
2439 double_property markersize , 6 |
|
2440 string_property keylabel , "" |
7379
|
2441 radio_property interpreter , "{tex}|none|latex" |
6874
|
2442 END_PROPERTIES |
|
2443 |
7363
|
2444 protected: |
|
2445 void init (void) |
|
2446 { |
|
2447 } |
6874
|
2448 }; |
|
2449 |
|
2450 private: |
|
2451 properties xproperties; |
|
2452 |
|
2453 public: |
|
2454 surface (const graphics_handle& mh, const graphics_handle& p) |
|
2455 : base_graphics_object (), xproperties (mh, p) |
|
2456 { |
|
2457 xproperties.override_defaults (*this); |
|
2458 } |
|
2459 |
|
2460 ~surface (void) { xproperties.delete_children (); } |
|
2461 |
|
2462 std::string type (void) const { return xproperties.graphics_object_name (); } |
|
2463 |
|
2464 void mark_modified (void) { xproperties.mark_modified (); } |
|
2465 |
|
2466 void override_defaults (base_graphics_object& obj) |
|
2467 { |
|
2468 // Allow parent (figure) to override first (properties knows how |
|
2469 // to find the parent object). |
|
2470 xproperties.override_defaults (obj); |
|
2471 } |
|
2472 |
|
2473 void set_from_list (property_list& plist) |
|
2474 { |
|
2475 xproperties.set_from_list (*this, plist); |
|
2476 } |
|
2477 |
7189
|
2478 void set (const caseless_str& name, const octave_value& val) |
6874
|
2479 { |
|
2480 xproperties.set (name, val); |
|
2481 } |
|
2482 |
7379
|
2483 octave_value get (bool all = false) const |
6874
|
2484 { |
7379
|
2485 return xproperties.get (all); |
6874
|
2486 } |
|
2487 |
7189
|
2488 octave_value get (const caseless_str& name) const |
6874
|
2489 { |
|
2490 return xproperties.get (name); |
|
2491 } |
|
2492 |
|
2493 graphics_handle get_parent (void) const { return xproperties.get_parent (); } |
|
2494 |
|
2495 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); } |
|
2496 |
|
2497 void adopt (const graphics_handle& h) { xproperties.adopt (h); } |
|
2498 |
|
2499 void reparent (const graphics_handle& h) { xproperties.reparent (h); } |
|
2500 |
|
2501 base_properties& get_properties (void) { return xproperties; } |
|
2502 |
7222
|
2503 const base_properties& get_properties (void) const { return xproperties; } |
|
2504 |
6890
|
2505 void defaults (void) const { gripe_not_implemented ("surface::defaults"); } |
|
2506 |
6874
|
2507 bool valid_object (void) const { return true; } |
|
2508 }; |
|
2509 |
|
2510 octave_value |
|
2511 get_property_from_handle (double handle, const std::string &property, |
|
2512 const std::string &func); |
|
2513 bool |
|
2514 set_property_in_handle (double handle, const std::string &property, |
|
2515 const octave_value &arg, const std::string &func); |
|
2516 |
|
2517 // --------------------------------------------------------------------- |
|
2518 |
7365
|
2519 class OCTINTERP_API gh_manager |
6874
|
2520 { |
|
2521 protected: |
|
2522 |
|
2523 gh_manager (void); |
|
2524 |
|
2525 public: |
|
2526 |
|
2527 static bool instance_ok (void) |
|
2528 { |
|
2529 bool retval = true; |
|
2530 |
|
2531 if (! instance) |
|
2532 instance = new gh_manager (); |
|
2533 |
|
2534 if (! instance) |
|
2535 { |
|
2536 ::error ("unable to create gh_manager!"); |
|
2537 |
|
2538 retval = false; |
|
2539 } |
|
2540 |
|
2541 return retval; |
|
2542 } |
|
2543 |
|
2544 static void free (const graphics_handle& h) |
|
2545 { |
|
2546 if (instance_ok ()) |
|
2547 instance->do_free (h); |
|
2548 } |
|
2549 |
|
2550 static graphics_handle lookup (double val) |
|
2551 { |
|
2552 return instance_ok () ? instance->do_lookup (val) : graphics_handle (); |
|
2553 } |
|
2554 |
|
2555 static graphics_object get_object (const graphics_handle& h) |
|
2556 { |
|
2557 return instance_ok () ? instance->do_get_object (h) : graphics_object (); |
|
2558 } |
|
2559 |
|
2560 static graphics_handle |
|
2561 make_graphics_handle (const std::string& go_name, |
7370
|
2562 const graphics_handle& parent, bool do_createfcn = true) |
6874
|
2563 { |
|
2564 return instance_ok () |
7370
|
2565 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn) |
6874
|
2566 : graphics_handle (); |
|
2567 } |
|
2568 |
|
2569 static graphics_handle make_figure_handle (double val) |
|
2570 { |
|
2571 return instance_ok () |
|
2572 ? instance->do_make_figure_handle (val) : graphics_handle (); |
|
2573 } |
|
2574 |
|
2575 static void push_figure (const graphics_handle& h) |
|
2576 { |
|
2577 if (instance_ok ()) |
|
2578 instance->do_push_figure (h); |
|
2579 } |
|
2580 |
|
2581 static void pop_figure (const graphics_handle& h) |
|
2582 { |
|
2583 if (instance_ok ()) |
|
2584 instance->do_pop_figure (h); |
|
2585 } |
|
2586 |
|
2587 static graphics_handle current_figure (void) |
|
2588 { |
|
2589 return instance_ok () |
|
2590 ? instance->do_current_figure () : graphics_handle (); |
|
2591 } |
|
2592 |
|
2593 static Matrix handle_list (void) |
|
2594 { |
|
2595 return instance_ok () ? instance->do_handle_list () : Matrix (); |
|
2596 } |
|
2597 |
|
2598 static Matrix figure_handle_list (void) |
|
2599 { |
|
2600 return instance_ok () ? instance->do_figure_handle_list () : Matrix (); |
|
2601 } |
|
2602 |
|
2603 private: |
|
2604 |
|
2605 static gh_manager *instance; |
|
2606 |
|
2607 typedef std::map<graphics_handle, graphics_object>::iterator iterator; |
|
2608 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator; |
|
2609 |
|
2610 typedef std::set<graphics_handle>::iterator free_list_iterator; |
|
2611 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator; |
|
2612 |
|
2613 typedef std::list<graphics_handle>::iterator figure_list_iterator; |
|
2614 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator; |
|
2615 |
|
2616 // A map of handles to graphics objects. |
|
2617 std::map<graphics_handle, graphics_object> handle_map; |
|
2618 |
|
2619 // The available graphics handles. |
|
2620 std::set<graphics_handle> handle_free_list; |
|
2621 |
|
2622 // The next handle available if handle_free_list is empty. |
7286
|
2623 double next_handle; |
6874
|
2624 |
|
2625 // The allocated figure handles. Top of the stack is most recently |
|
2626 // created. |
|
2627 std::list<graphics_handle> figure_list; |
|
2628 |
|
2629 graphics_handle get_handle (const std::string& go_name); |
|
2630 |
|
2631 void do_free (const graphics_handle& h); |
|
2632 |
|
2633 graphics_handle do_lookup (double val) |
|
2634 { |
7363
|
2635 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val)); |
6874
|
2636 |
|
2637 return (p != handle_map.end ()) ? p->first : graphics_handle (); |
|
2638 } |
|
2639 |
|
2640 graphics_object do_get_object (const graphics_handle& h) |
|
2641 { |
7379
|
2642 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); |
6874
|
2643 |
|
2644 return (p != handle_map.end ()) ? p->second : graphics_object (); |
|
2645 } |
|
2646 |
|
2647 graphics_handle do_make_graphics_handle (const std::string& go_name, |
7370
|
2648 const graphics_handle& p, bool do_createfcn); |
6874
|
2649 |
|
2650 graphics_handle do_make_figure_handle (double val); |
|
2651 |
|
2652 Matrix do_handle_list (void) |
|
2653 { |
|
2654 Matrix retval (1, handle_map.size ()); |
|
2655 octave_idx_type i = 0; |
|
2656 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) |
7056
|
2657 { |
|
2658 graphics_handle h = p->first; |
|
2659 retval(i++) = h.value (); |
|
2660 } |
6874
|
2661 return retval; |
|
2662 } |
|
2663 |
|
2664 Matrix do_figure_handle_list (void) |
|
2665 { |
|
2666 Matrix retval (1, figure_list.size ()); |
|
2667 octave_idx_type i = 0; |
|
2668 for (const_figure_list_iterator p = figure_list.begin (); |
|
2669 p != figure_list.end (); |
|
2670 p++) |
7056
|
2671 { |
|
2672 graphics_handle h = *p; |
|
2673 retval(i++) = h.value (); |
|
2674 } |
6874
|
2675 return retval; |
|
2676 } |
|
2677 |
|
2678 void do_push_figure (const graphics_handle& h); |
|
2679 |
|
2680 void do_pop_figure (const graphics_handle& h); |
|
2681 |
|
2682 graphics_handle do_current_figure (void) const |
|
2683 { |
|
2684 return figure_list.empty () ? graphics_handle () : figure_list.front (); |
|
2685 } |
|
2686 }; |
|
2687 |
|
2688 |
|
2689 // This function is NOT equivalent to the scripting language function gcf. |
7365
|
2690 OCTINTERP_API graphics_handle gcf (void); |
6874
|
2691 |
|
2692 // This function is NOT equivalent to the scripting language function gca. |
7365
|
2693 OCTINTERP_API graphics_handle gca (void); |
6874
|
2694 |
|
2695 #endif |
|
2696 |
|
2697 /* |
|
2698 ;;; Local Variables: *** |
|
2699 ;;; mode: C++ *** |
|
2700 ;;; End: *** |
|
2701 */ |