Mercurial > octave
annotate src/graphics.h.in @ 7822:edbaa13397ee
Implement callbackobject property in root object.
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 07 Feb 2008 23:00:51 +0100 |
parents | f79dcba526a8 |
children | adb520646d7e |
rev | line source |
---|---|
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 | |
7427 | 185 class base_scaler |
186 { | |
187 public: | |
188 base_scaler (void) { } | |
189 | |
7441 | 190 virtual ~base_scaler (void) { } |
7440 | 191 |
7427 | 192 virtual Matrix scale (const Matrix& m) const |
193 { | |
194 error ("invalid axis scale"); | |
195 return m; | |
196 } | |
197 | |
198 virtual double scale (double d) const | |
199 { | |
200 error ("invalid axis scale"); | |
201 return d; | |
202 } | |
203 | |
204 virtual double unscale (double d) const | |
205 { | |
206 error ("invalid axis scale"); | |
207 return d; | |
208 } | |
209 | |
210 virtual base_scaler* clone () const | |
211 { return new base_scaler (); } | |
212 }; | |
213 | |
214 class lin_scaler : public base_scaler | |
215 { | |
216 public: | |
217 lin_scaler (void) { } | |
218 | |
219 Matrix scale (const Matrix& m) const { return m; } | |
220 | |
221 double scale (double d) const { return d; } | |
222 | |
223 double unscale (double d) const { return d; } | |
224 | |
225 base_scaler* clone (void) const { return new lin_scaler (); } | |
226 }; | |
227 | |
228 class log_scaler : public base_scaler | |
229 { | |
230 public: | |
231 log_scaler (void) { } | |
232 | |
233 Matrix scale (const Matrix& m) const | |
234 { | |
235 Matrix retval (m.rows (), m.cols ()); | |
236 const double *d1 = m.fortran_vec (); | |
237 double *d2 = retval.fortran_vec (); | |
238 | |
239 for (int i = 0; i < m.numel (); i++) | |
240 d2[i] = log10 (d1[i]); | |
241 | |
242 return retval; | |
243 } | |
244 | |
245 double scale (double d) const | |
246 { return log10 (d); } | |
247 | |
248 double unscale (double d) const | |
249 { return pow (10.0, d); } | |
250 | |
251 base_scaler* clone (void) const | |
252 { return new log_scaler (); } | |
253 }; | |
254 | |
255 class scaler | |
256 { | |
257 public: | |
258 scaler (void) : rep (new base_scaler ()) { } | |
259 | |
260 scaler (const scaler& s) : rep (s.rep->clone()) { } | |
261 | |
262 ~scaler (void) { delete rep; } | |
263 | |
264 Matrix scale (const Matrix& m) const | |
265 { return rep->scale (m); } | |
266 | |
267 double scale (double d) const | |
268 { return rep->scale (d); } | |
269 | |
270 double unscale (double d) const | |
271 { return rep->unscale (d); } | |
272 | |
273 scaler& operator = (const scaler& s) | |
274 { | |
275 if (rep) | |
276 { | |
277 delete rep; | |
278 rep = 0; | |
279 } | |
280 | |
281 rep = s.rep->clone (); | |
282 | |
283 return *this; | |
284 } | |
285 | |
286 scaler& operator = (const std::string& s) | |
287 { | |
288 if (rep) | |
289 { | |
290 delete rep; | |
291 rep = 0; | |
292 } | |
293 | |
294 if (s == "log") | |
295 rep = new log_scaler (); | |
296 else if (s == "linear") | |
297 rep = new lin_scaler (); | |
298 else | |
299 rep = new base_scaler (); | |
300 | |
301 return *this; | |
302 } | |
303 | |
304 private: | |
305 base_scaler *rep; | |
306 }; | |
307 | |
308 // --------------------------------------------------------------------- | |
309 | |
7363 | 310 class property; |
311 | |
312 class base_property | |
313 { | |
314 public: | |
315 friend class property; | |
316 | |
317 public: | |
318 base_property (void) : count (0) { } | |
319 | |
320 base_property (const std::string& s, const graphics_handle& h) | |
321 : count (0), name (s), parent (h), hidden (false) { } | |
322 | |
323 base_property (const base_property& p) | |
324 : count (0), name (p.name), parent (p.parent), hidden (p.hidden) { } | |
325 | |
326 virtual ~base_property (void) { } | |
327 | |
328 bool ok (void) const { return parent.ok (); } | |
329 | |
330 std::string get_name (void) const { return name; } | |
331 | |
332 void set_name (const std::string& s) { name = s; } | |
333 | |
334 graphics_handle get_parent (void) const { return parent; } | |
335 | |
336 void set_parent (const graphics_handle &h) { parent = h; } | |
337 | |
338 bool is_hidden (void) const { return hidden; } | |
339 | |
340 void set_hidden (bool flag) { hidden = flag; } | |
341 | |
7364 | 342 virtual void set (const octave_value&) |
7363 | 343 { error ("set: invalid property \"%s\"", name.c_str ()); } |
344 | |
345 virtual octave_value get (void) const | |
346 { | |
347 error ("get: invalid property \"%s\"", name.c_str ()); | |
348 return octave_value (); | |
349 } | |
350 | |
351 base_property& operator = (const octave_value& val) | |
352 { | |
353 set (val); | |
354 return *this; | |
355 } | |
356 | |
357 private: | |
358 int count; | |
359 std::string name; | |
360 graphics_handle parent; | |
361 bool hidden; | |
362 }; | |
363 | |
364 // --------------------------------------------------------------------- | |
365 | |
366 class string_property : public base_property | |
367 { | |
368 public: | |
369 string_property (const std::string& s, const graphics_handle& h, | |
370 const std::string& val = "") | |
371 : base_property (s, h), str (val) { } | |
372 | |
373 string_property (const string_property& p) | |
374 : base_property (p), str (p.str) { } | |
375 | |
376 void set (const octave_value& val) | |
377 { | |
378 if (val.is_string ()) | |
379 str = val.string_value (); | |
380 else | |
381 error ("set: invalid string property value for \"%s\"", | |
382 get_name ().c_str ()); | |
383 } | |
384 | |
385 octave_value get (void) const | |
386 { return octave_value (str); } | |
387 | |
388 std::string string_value (void) const { return str; } | |
389 | |
390 string_property& operator = (const octave_value& val) | |
391 { | |
392 set (val); | |
393 return *this; | |
394 } | |
395 | |
396 private: | |
397 std::string str; | |
398 }; | |
399 | |
400 // --------------------------------------------------------------------- | |
401 | |
402 class radio_values | |
403 { | |
404 public: | |
405 OCTINTERP_API radio_values (const std::string& opt_string = std::string ()); | |
406 | |
407 radio_values (const radio_values& a) | |
408 : default_val (a.default_val), possible_vals (a.possible_vals) { } | |
409 | |
410 radio_values& operator = (const radio_values& a) | |
411 { | |
412 if (&a != this) | |
413 { | |
414 default_val = a.default_val; | |
415 possible_vals = a.possible_vals; | |
416 } | |
417 | |
418 return *this; | |
419 } | |
420 | |
421 std::string default_value (void) const { return default_val; } | |
422 | |
423 bool validate (const std::string& val) | |
424 { | |
425 bool retval = true; | |
426 | |
427 if (! contains (val)) | |
428 { | |
429 error ("invalid value = %s", val.c_str ()); | |
430 retval = false; | |
431 } | |
432 | |
433 return retval; | |
434 } | |
435 | |
436 bool contains (const std::string& val) | |
437 { | |
438 return (possible_vals.find (val) != possible_vals.end ()); | |
439 } | |
440 | |
441 private: | |
442 // Might also want to cache | |
443 std::string default_val; | |
444 std::set<caseless_str> possible_vals; | |
445 }; | |
446 | |
447 class radio_property : public base_property | |
448 { | |
449 public: | |
7364 | 450 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 451 const radio_values& v = radio_values ()) |
7364 | 452 : base_property (nm, h), |
7363 | 453 vals (v), current_val (v.default_value ()) { } |
454 | |
7364 | 455 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 456 const std::string& v) |
7364 | 457 : base_property (nm, h), |
7363 | 458 vals (v), current_val (vals.default_value ()) { } |
459 | |
7364 | 460 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 461 const radio_values& v, const std::string& def) |
7364 | 462 : base_property (nm, h), |
7363 | 463 vals (v), current_val (def) { } |
464 | |
465 radio_property (const radio_property& p) | |
466 : base_property (p), vals (p.vals), current_val (p.current_val) { } | |
467 | |
468 void set (const octave_value& newval) | |
469 { | |
470 if (newval.is_string ()) | |
471 { | |
472 std::string s = newval.string_value (); | |
473 if (vals.validate (s)) | |
474 current_val = s; | |
475 else | |
476 error ("set: invalid value for radio property \"%s\" (value = %s)", | |
477 get_name ().c_str (), s.c_str ()); | |
478 } | |
479 else | |
480 error ("set: invalid value for radio property \"%s\"", | |
481 get_name ().c_str ()); | |
482 } | |
483 | |
484 octave_value get (void) const { return octave_value (current_val); } | |
485 | |
486 const std::string& current_value (void) const { return current_val; } | |
487 | |
488 bool is (const caseless_str& v) const | |
489 { return v.compare (current_val); } | |
490 | |
491 radio_property& operator = (const octave_value& val) | |
492 { | |
493 set (val); | |
494 return *this; | |
495 } | |
496 | |
497 private: | |
498 radio_values vals; | |
499 std::string current_val; | |
500 }; | |
501 | |
502 // --------------------------------------------------------------------- | |
503 | |
504 class color_values | |
505 { | |
506 public: | |
507 color_values (double r = 0, double g = 0, double b = 1) | |
508 : xrgb (1, 3) | |
509 { | |
510 xrgb(0) = r; | |
511 xrgb(1) = g; | |
512 xrgb(2) = b; | |
513 | |
514 validate (); | |
515 } | |
516 | |
517 color_values (std::string str) | |
518 : xrgb (1, 3) | |
519 { | |
520 if (! str2rgb (str)) | |
521 error ("invalid color specification: %s", str.c_str ()); | |
522 } | |
523 | |
524 color_values (const color_values& c) | |
525 : xrgb (c.xrgb) | |
526 { } | |
527 | |
528 color_values& operator = (const color_values& c) | |
529 { | |
530 if (&c != this) | |
531 xrgb = c.xrgb; | |
532 | |
533 return *this; | |
534 } | |
535 | |
536 Matrix rgb (void) const { return xrgb; } | |
537 | |
538 operator octave_value (void) const { return xrgb; } | |
539 | |
540 void validate (void) const | |
541 { | |
542 for (int i = 0; i < 3; i++) | |
543 { | |
544 if (xrgb(i) < 0 || xrgb(i) > 1) | |
545 { | |
546 error ("invalid RGB color specification"); | |
547 break; | |
548 } | |
549 } | |
550 } | |
551 | |
552 private: | |
553 Matrix xrgb; | |
554 | |
555 OCTINTERP_API bool str2rgb (std::string str); | |
556 }; | |
557 | |
558 class color_property : public base_property | |
559 { | |
560 public: | |
561 color_property (const color_values& c, const radio_values& v) | |
562 : base_property ("", graphics_handle ()), | |
563 current_type (color_t), color_val (c), radio_val (v), | |
564 current_val (v.default_value ()) | |
565 { } | |
566 | |
7364 | 567 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 568 const color_values& c = color_values (), |
569 const radio_values& v = radio_values ()) | |
7364 | 570 : base_property (nm, h), |
7363 | 571 current_type (color_t), color_val (c), radio_val (v), |
572 current_val (v.default_value ()) | |
573 { } | |
574 | |
7364 | 575 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 576 const radio_values& v) |
7364 | 577 : base_property (nm, h), |
7363 | 578 current_type (radio_t), color_val (color_values ()), radio_val (v), |
579 current_val (v.default_value ()) | |
580 { } | |
581 | |
7364 | 582 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 583 const std::string& v) |
7364 | 584 : base_property (nm, h), |
7363 | 585 current_type (radio_t), color_val (color_values ()), radio_val (v), |
586 current_val (radio_val.default_value ()) | |
587 { } | |
588 | |
7364 | 589 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 590 const color_property& v) |
7364 | 591 : base_property (nm, h), |
7363 | 592 current_type (v.current_type), color_val (v.color_val), |
593 radio_val (v.radio_val), current_val (v.current_val) | |
594 { } | |
595 | |
596 color_property (const color_property& p) | |
597 : base_property (p), current_type (p.current_type), | |
598 color_val (p.color_val), radio_val (p.radio_val), | |
599 current_val (p.current_val) { } | |
600 | |
601 octave_value get (void) const | |
602 { | |
603 if (current_type == color_t) | |
604 return color_val.rgb (); | |
605 | |
606 return current_val; | |
607 } | |
608 | |
609 OCTINTERP_API void set (const octave_value& newval); | |
610 | |
611 bool is_rgb (void) const { return (current_type == color_t); } | |
612 | |
613 bool is_radio (void) const { return (current_type == radio_t); } | |
614 | |
615 bool is (const std::string& v) const | |
616 { return (is_radio () && current_val == v); } | |
617 | |
618 Matrix rgb (void) const | |
619 { | |
620 if (current_type != color_t) | |
621 error ("color has no rgb value"); | |
622 | |
623 return color_val.rgb (); | |
624 } | |
625 | |
626 const std::string& current_value (void) const | |
627 { | |
628 if (current_type != radio_t) | |
629 error ("color has no radio value"); | |
630 | |
631 return current_val; | |
632 } | |
633 | |
634 color_property& operator = (const octave_value& val) | |
635 { | |
636 set (val); | |
637 return *this; | |
638 } | |
639 | |
640 operator octave_value (void) const { return get (); } | |
641 | |
642 private: | |
643 enum current_enum { color_t, radio_t } current_type; | |
644 color_values color_val; | |
645 radio_values radio_val; | |
646 std::string current_val; | |
647 }; | |
648 | |
649 // --------------------------------------------------------------------- | |
650 | |
651 class double_property : public base_property | |
652 { | |
653 public: | |
7364 | 654 double_property (const std::string& nm, const graphics_handle& h, |
7363 | 655 double d = 0) |
7364 | 656 : base_property (nm, h), |
7363 | 657 current_val (d) { } |
658 | |
659 double_property (const double_property& p) | |
660 : base_property (p), current_val (p.current_val) { } | |
661 | |
662 void set (const octave_value& v) | |
663 { | |
664 if (v.is_scalar_type () && v.is_real_type ()) | |
665 current_val = v.double_value (); | |
666 else | |
667 error ("set: invalid value for double property \"%s\"", | |
668 get_name ().c_str ()); | |
669 } | |
670 | |
671 octave_value get (void) const { return octave_value (current_val); } | |
672 | |
673 double double_value (void) const { return current_val; } | |
674 | |
675 double_property& operator = (const octave_value& val) | |
676 { | |
677 set (val); | |
678 return *this; | |
679 } | |
680 | |
681 private: | |
682 double current_val; | |
683 }; | |
684 | |
685 // --------------------------------------------------------------------- | |
686 | |
687 class array_property : public base_property | |
688 { | |
689 public: | |
7364 | 690 array_property (const std::string& nm, const graphics_handle& h, |
7363 | 691 const octave_value& m) |
7364 | 692 : base_property (nm, h), data (m) { } |
7363 | 693 |
694 octave_value get (void) const { return data; } | |
695 | |
696 void set (const octave_value& v) | |
697 { | |
698 if (validate (v)) | |
699 data = v; | |
700 else | |
701 error ("invalid value for array property \"%s\"", | |
702 get_name ().c_str ()); | |
703 } | |
704 | |
705 void add_constraint (const std::string& type) | |
706 { type_constraints.push_back (type); } | |
707 | |
7524
a653856aa3e1
array_value::add_constraint: pass dim_vector as const reference, not value
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
708 void add_constraint (const dim_vector& dims) |
7363 | 709 { size_constraints.push_back (dims); } |
710 | |
711 array_property& operator = (const octave_value& val) | |
712 { | |
713 set (val); | |
714 return *this; | |
715 } | |
716 | |
717 private: | |
718 OCTINTERP_API bool validate (const octave_value& v); | |
719 | |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
720 protected: |
7363 | 721 octave_value data; |
722 std::list<std::string> type_constraints; | |
723 std::list<dim_vector> size_constraints; | |
724 }; | |
725 | |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
726 class row_vector_property : public array_property |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
727 { |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
728 public: |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
729 row_vector_property (const std::string& nm, const graphics_handle& h, |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
730 const octave_value& m) |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
731 : array_property (nm, h, m) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
732 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
733 add_constraint (dim_vector (-1, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
734 add_constraint (dim_vector (1, -1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
735 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
736 |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
737 void set (const octave_value& v) |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
738 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
739 array_property::set (v); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
740 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
741 if (! error_state) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
742 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
743 dim_vector dv = data.dims (); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
744 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
745 if (dv(0) > 1 && dv(1) == 1) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
746 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
747 int tmp = dv(0); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
748 dv(0) = dv(1); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
749 dv(1) = tmp; |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
750 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
751 data = data.reshape (dv); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
752 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
753 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
754 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
755 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
756 void add_constraint (const std::string& type) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
757 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
758 array_property::add_constraint (type); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
759 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
760 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
761 void add_constraint (const dim_vector& dims) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
762 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
763 array_property::add_constraint (dims); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
764 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
765 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
766 void add_constraint (octave_idx_type len) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
767 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
768 size_constraints.remove (dim_vector (1, -1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
769 size_constraints.remove (dim_vector (-1, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
770 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
771 add_constraint (dim_vector (1, len)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
772 add_constraint (dim_vector (len, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
773 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
774 |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
775 row_vector_property& operator = (const octave_value& val) |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
776 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
777 set (val); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
778 return *this; |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
779 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
780 |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
781 private: |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
782 OCTINTERP_API bool validate (const octave_value& v); |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
783 }; |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
784 |
7363 | 785 // --------------------------------------------------------------------- |
786 | |
787 class data_property : public base_property | |
788 { | |
789 public: | |
790 data_property (void) | |
791 : base_property ("", graphics_handle ()) { } | |
792 | |
7364 | 793 data_property (const std::string& nm, const graphics_handle& h, |
7363 | 794 const NDArray& m = NDArray ()) |
7364 | 795 : base_property (nm, h), |
7363 | 796 data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) |
797 { | |
798 get_data_limits (); | |
799 } | |
800 | |
7364 | 801 data_property (const std::string& nm, const graphics_handle& h, |
7363 | 802 const Matrix& m) |
7364 | 803 : base_property (nm, h), |
7363 | 804 data (m), xmin (octave_Inf), xmax (-octave_Inf), xminp (octave_Inf) |
805 { | |
806 get_data_limits (); | |
807 } | |
808 | |
809 data_property (const data_property& p) | |
810 : base_property (p), data (p.data), | |
811 xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } | |
812 | |
813 void set (const octave_value& val) | |
814 { | |
815 data = val.array_value (); | |
816 | |
817 get_data_limits (); | |
818 } | |
819 | |
820 octave_value get (void) const { return data; } | |
821 | |
822 NDArray array_value (void) const { return data; } | |
823 | |
824 Matrix matrix_value (void) const { return data.matrix_value (); } | |
825 | |
826 double min_val (void) const { return xmin; } | |
827 double max_val (void) const { return xmax; } | |
828 double min_pos (void) const { return xminp; } | |
829 | |
830 data_property& operator = (const octave_value& val) | |
831 { | |
832 set (val); | |
833 return *this; | |
834 } | |
835 | |
836 private: | |
837 NDArray data; | |
838 double xmin; | |
839 double xmax; | |
840 double xminp; | |
841 | |
842 void get_data_limits (void) | |
843 { | |
844 octave_idx_type nel = data.numel (); | |
845 | |
7395 | 846 xmin = xminp = octave_Inf; |
847 xmax = -octave_Inf; | |
848 | |
7363 | 849 if (nel > 0) |
850 { | |
851 const double *d = data.data (); | |
852 | |
853 for (octave_idx_type i = 0; i < nel; i++) | |
854 { | |
855 double val = d[i]; | |
856 | |
857 if (! (xisinf (val) || xisnan (val))) | |
858 { | |
859 if (val < xmin) | |
860 xmin = val; | |
861 | |
862 if (val > xmax) | |
863 xmax = val; | |
864 | |
865 if (val > 0 && val < xminp) | |
866 xminp = val; | |
867 } | |
868 } | |
869 } | |
870 } | |
871 }; | |
872 | |
873 // --------------------------------------------------------------------- | |
874 | |
875 class bool_property : public radio_property | |
876 { | |
877 public: | |
7364 | 878 bool_property (const std::string& nm, const graphics_handle& h, |
7363 | 879 bool val) |
7364 | 880 : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}")) |
7363 | 881 { } |
882 | |
7364 | 883 bool_property (const std::string& nm, const graphics_handle& h, |
7363 | 884 const char* val) |
7364 | 885 : radio_property (nm, h, radio_values ("on|off"), val) |
7363 | 886 { } |
887 | |
888 bool_property (const bool_property& p) | |
889 : radio_property (p) { } | |
890 | |
891 void set (const octave_value& val) | |
892 { | |
893 if (val.is_bool_scalar ()) | |
894 radio_property::set (val.bool_value () ? "on" : "off"); | |
895 else | |
896 radio_property::set (val); | |
897 } | |
898 | |
899 bool is_on (void) const { return is ("on"); } | |
900 | |
901 bool_property& operator = (const octave_value& val) | |
902 { | |
903 set (val); | |
904 return *this; | |
905 } | |
906 }; | |
907 | |
908 // --------------------------------------------------------------------- | |
909 | |
910 class handle_property : public base_property | |
911 { | |
912 public: | |
7364 | 913 handle_property (const std::string& nm, const graphics_handle& h, |
7363 | 914 const graphics_handle& val = graphics_handle ()) |
7364 | 915 : base_property (nm, h), |
7363 | 916 current_val (val) { } |
917 | |
918 handle_property (const handle_property& p) | |
919 : base_property (p), current_val (p.current_val) { } | |
920 | |
921 OCTINTERP_API void set (const octave_value& v); | |
922 | |
923 octave_value get (void) const { return current_val.as_octave_value (); } | |
924 | |
925 graphics_handle handle_value (void) const { return current_val; } | |
926 | |
927 handle_property& operator = (const octave_value& val) | |
928 { | |
929 set (val); | |
930 return *this; | |
931 } | |
932 | |
933 handle_property& operator = (const graphics_handle& h) | |
934 { | |
935 set (octave_value (h.value ())); | |
936 return *this; | |
937 } | |
938 | |
939 private: | |
940 graphics_handle current_val; | |
941 }; | |
942 | |
943 // --------------------------------------------------------------------- | |
944 | |
945 class any_property : public base_property | |
946 { | |
947 public: | |
7364 | 948 any_property (const std::string& nm, const graphics_handle& h, |
7363 | 949 const octave_value& m = Matrix ()) |
7364 | 950 : base_property (nm, h), data (m) { } |
7363 | 951 |
952 octave_value get (void) const { return data; } | |
953 | |
954 void set (const octave_value& v) { data = v; } | |
955 | |
956 any_property& operator = (const octave_value& val) | |
957 { | |
958 set (val); | |
959 return *this; | |
960 } | |
961 | |
962 private: | |
963 octave_value data; | |
964 }; | |
965 | |
966 // --------------------------------------------------------------------- | |
967 | |
968 class callback_property : public base_property | |
969 { | |
970 public: | |
7364 | 971 callback_property (const std::string& nm, const graphics_handle& h, |
7363 | 972 const octave_value& m) |
7364 | 973 : base_property (nm, h), callback (m) { } |
7363 | 974 |
975 octave_value get (void) const { return callback; } | |
976 | |
977 void set (const octave_value& v) | |
978 { | |
979 if (validate (v)) | |
980 callback = v; | |
981 else | |
982 error ("invalid value for callback property \"%s\"", | |
983 get_name ().c_str ()); | |
984 } | |
985 | |
7367 | 986 OCTINTERP_API void execute (const octave_value& data = octave_value ()) const; |
7363 | 987 |
988 callback_property& operator = (const octave_value& val) | |
989 { | |
990 set (val); | |
991 return *this; | |
992 } | |
993 | |
994 private: | |
995 OCTINTERP_API bool validate (const octave_value& v) const; | |
996 | |
997 private: | |
998 octave_value callback; | |
999 }; | |
1000 | |
1001 // --------------------------------------------------------------------- | |
1002 | |
1003 class property | |
1004 { | |
1005 public: | |
1006 property (void) : rep (new base_property ("", graphics_handle ())) | |
1007 { rep->count++; } | |
1008 | |
1009 property (base_property *bp, bool persist = false) : rep (bp) | |
1010 { rep->count++; if (persist) rep->count++; } | |
1011 | |
1012 property (const property& p) | |
1013 { | |
1014 rep = p.rep; | |
1015 rep->count++; | |
1016 } | |
1017 | |
1018 ~property (void) | |
1019 { | |
1020 if (--rep->count <= 0) | |
1021 delete rep; | |
1022 } | |
1023 | |
1024 bool ok (void) const | |
1025 { return rep->ok (); } | |
1026 | |
1027 std::string get_name (void) const | |
1028 { return rep->get_name (); } | |
1029 | |
1030 void set_name (const std::string& name) | |
1031 { rep->set_name (name); } | |
1032 | |
1033 graphics_handle get_parent (void) const | |
1034 { return rep->get_parent (); } | |
1035 | |
1036 void set_parent (const graphics_handle& h) | |
1037 { rep->set_parent (h); } | |
1038 | |
1039 bool is_hidden (void) const | |
1040 { return rep->is_hidden (); } | |
1041 | |
1042 void set_hidden (bool flag) | |
1043 { rep->set_hidden (flag); } | |
1044 | |
1045 octave_value get (void) const | |
1046 { return rep->get (); } | |
1047 | |
1048 void set (const octave_value& val) | |
1049 { rep->set (val); } | |
1050 | |
1051 property& operator = (const octave_value& val) | |
1052 { | |
1053 *rep = val; | |
1054 return *this; | |
1055 } | |
1056 | |
1057 property& operator = (const property& p) | |
1058 { | |
1059 if (rep && --rep->count <= 0) | |
1060 delete rep; | |
1061 | |
1062 rep = p.rep; | |
1063 rep->count++; | |
1064 | |
1065 return *this; | |
1066 } | |
1067 | |
1068 /* | |
1069 const string_property& as_string_property (void) const | |
1070 { return *(dynamic_cast<string_property*> (rep)); } | |
1071 | |
1072 const radio_property& as_radio_property (void) const | |
1073 { return *(dynamic_cast<radio_property*> (rep)); } | |
1074 | |
1075 const color_property& as_color_property (void) const | |
1076 { return *(dynamic_cast<color_property*> (rep)); } | |
1077 | |
1078 const double_property& as_double_property (void) const | |
1079 { return *(dynamic_cast<double_property*> (rep)); } | |
1080 | |
1081 const data_property& as_data_property (void) const | |
1082 { return *(dynamic_cast<data_property*> (rep)); } | |
1083 | |
1084 const bool_property& as_bool_property (void) const | |
1085 { return *(dynamic_cast<bool_property*> (rep)); } | |
1086 | |
1087 const handle_property& as_handle_property (void) const | |
1088 { return *(dynamic_cast<handle_property*> (rep)); } | |
1089 */ | |
1090 | |
1091 private: | |
1092 base_property *rep; | |
1093 }; | |
1094 | |
1095 // --------------------------------------------------------------------- | |
1096 | |
1097 class property_list | |
1098 { | |
1099 public: | |
1100 typedef std::map<std::string, octave_value> pval_map_type; | |
1101 typedef std::map<std::string, pval_map_type> plist_map_type; | |
1102 | |
1103 typedef pval_map_type::iterator pval_map_iterator; | |
1104 typedef pval_map_type::const_iterator pval_map_const_iterator; | |
1105 | |
1106 typedef plist_map_type::iterator plist_map_iterator; | |
1107 typedef plist_map_type::const_iterator plist_map_const_iterator; | |
1108 | |
1109 property_list (const plist_map_type& m = plist_map_type ()) | |
1110 : plist_map (m) { } | |
1111 | |
1112 ~property_list (void) { } | |
1113 | |
1114 void set (const caseless_str& name, const octave_value& val); | |
1115 | |
1116 octave_value lookup (const caseless_str& name) const; | |
1117 | |
1118 plist_map_iterator begin (void) { return plist_map.begin (); } | |
1119 plist_map_const_iterator begin (void) const { return plist_map.begin (); } | |
1120 | |
1121 plist_map_iterator end (void) { return plist_map.end (); } | |
1122 plist_map_const_iterator end (void) const { return plist_map.end (); } | |
1123 | |
1124 plist_map_iterator find (const std::string& go_name) | |
1125 { | |
1126 return plist_map.find (go_name); | |
1127 } | |
1128 | |
1129 plist_map_const_iterator find (const std::string& go_name) const | |
1130 { | |
1131 return plist_map.find (go_name); | |
1132 } | |
1133 | |
1134 Octave_map as_struct (const std::string& prefix_arg) const; | |
1135 | |
1136 private: | |
1137 plist_map_type plist_map; | |
1138 }; | |
1139 | |
1140 // --------------------------------------------------------------------- | |
1141 | |
7419 | 1142 class graphics_backend; |
1143 | |
1144 class base_graphics_backend | |
1145 { | |
1146 public: | |
1147 friend class graphics_backend; | |
1148 | |
1149 public: | |
1150 base_graphics_backend (const std::string& nm) | |
1151 : name (nm), count (0) { } | |
1152 | |
1153 virtual ~base_graphics_backend (void) { } | |
1154 | |
1155 std::string get_name (void) const { return name; } | |
1156 | |
1157 virtual bool is_valid (void) const { return false; } | |
1158 | |
1159 virtual void close_figure (const octave_value&) const | |
1160 { error ("close_figure: invalid graphics backend"); } | |
1161 | |
1162 virtual void redraw_figure (const graphics_handle&) const | |
1163 { error ("redraw_figure: invalid graphics backend"); } | |
1164 | |
1165 virtual void print_figure (const graphics_handle&, const std::string&, | |
1166 const std::string&, bool, | |
1167 const std::string& = "") const | |
1168 { error ("print_figure: invalid graphics backend"); } | |
1169 | |
1170 virtual Matrix get_canvas_size (const graphics_handle&) const | |
1171 { | |
1172 error ("get_canvas_size: invalid graphics backend"); | |
1173 return Matrix (1, 2, 0.0); | |
1174 } | |
1175 | |
7427 | 1176 virtual double get_screen_resolution (void) const |
1177 { | |
1178 error ("get_screen_resolution: invalid graphics backend"); | |
1179 return -1; | |
1180 } | |
7445 | 1181 |
1182 virtual Matrix get_screen_size (void) const | |
1183 { | |
1184 error ("get_screen_size: invalid graphics backend"); | |
1185 return Matrix (1, 2, 0.0); | |
1186 } | |
7427 | 1187 |
7419 | 1188 private: |
1189 std::string name; | |
1190 int count; | |
1191 }; | |
1192 | |
1193 class graphics_backend | |
1194 { | |
1195 public: | |
1196 graphics_backend (void) | |
1197 : rep (new base_graphics_backend ("unknown")) | |
1198 { | |
1199 rep->count++; | |
1200 } | |
1201 | |
1202 graphics_backend (base_graphics_backend* b) | |
1203 : rep (b) | |
1204 { | |
1205 rep->count++; | |
1206 } | |
1207 | |
1208 graphics_backend (const graphics_backend& b) | |
1209 : rep (b.rep) | |
1210 { | |
1211 rep->count++; | |
1212 } | |
1213 | |
1214 ~graphics_backend (void) | |
1215 { | |
1216 if (--rep->count == 0) | |
1217 delete rep; | |
1218 } | |
1219 | |
1220 graphics_backend& operator = (const graphics_backend& b) | |
1221 { | |
1222 if (rep != b.rep) | |
1223 { | |
1224 if (--rep->count == 0) | |
1225 delete rep; | |
1226 | |
1227 rep = b.rep; | |
1228 rep->count++; | |
1229 } | |
1230 | |
1231 return *this; | |
1232 } | |
1233 | |
1234 operator bool (void) const { return rep->is_valid (); } | |
1235 | |
1236 std::string get_name (void) const { return rep->get_name (); } | |
1237 | |
1238 void close_figure (const octave_value& pstream) const | |
1239 { rep->close_figure (pstream); } | |
1240 | |
1241 void redraw_figure (const graphics_handle& fh) const | |
1242 { rep->redraw_figure (fh); } | |
1243 | |
1244 void print_figure (const graphics_handle& fh, const std::string& term, | |
1245 const std::string& file, bool mono, | |
1246 const std::string& debug_file = "") const | |
1247 { rep->print_figure (fh, term, file, mono, debug_file); } | |
1248 | |
1249 Matrix get_canvas_size (const graphics_handle& fh) const | |
1250 { return rep->get_canvas_size (fh); } | |
1251 | |
7427 | 1252 double get_screen_resolution (void) const |
1253 { return rep->get_screen_resolution (); } | |
1254 | |
7445 | 1255 Matrix get_screen_size (void) const |
1256 { return rep->get_screen_size (); } | |
1257 | |
7419 | 1258 OCTINTERP_API static graphics_backend default_backend (void); |
1259 | |
1260 static void register_backend (const graphics_backend& b) | |
1261 { available_backends[b.get_name ()] = b; } | |
1262 | |
1263 static void unregister_backend (const std::string& name) | |
1264 { available_backends.erase (name); } | |
1265 | |
7439 | 1266 static graphics_backend find_backend (const std::string& name) |
1267 { | |
1268 const_available_backends_iterator p = available_backends.find (name); | |
1269 | |
1270 if (p != available_backends.end ()) | |
1271 return p->second; | |
1272 else | |
1273 return default_backend (); | |
1274 } | |
1275 | |
7419 | 1276 private: |
1277 base_graphics_backend *rep; | |
1278 | |
7445 | 1279 static OCTINTERP_API std::map<std::string, graphics_backend> available_backends; |
7439 | 1280 |
1281 typedef std::map<std::string, graphics_backend>::iterator available_backends_iterator; | |
1282 typedef std::map<std::string, graphics_backend>::const_iterator const_available_backends_iterator; | |
7419 | 1283 }; |
1284 | |
1285 // --------------------------------------------------------------------- | |
1286 | |
6874 | 1287 class base_graphics_object; |
1288 | |
7365 | 1289 class OCTINTERP_API base_properties |
6874 | 1290 { |
1291 public: | |
7176 | 1292 base_properties (const std::string& ty = "unknown", |
7363 | 1293 const graphics_handle& mh = graphics_handle (), |
1294 const graphics_handle& p = graphics_handle ()) | |
7404 | 1295 : beingdeleted ("beingdeleted", mh, false), |
7366 | 1296 busyaction ("parent", mh, "{queue}|cancel"), |
7367 | 1297 buttondownfcn ("buttondownfcn", mh, Matrix ()), |
7404 | 1298 children (), |
7366 | 1299 clipping ("clipping", mh, true), |
7406 | 1300 createfcn ("createfcn", mh, Matrix ()), |
7367 | 1301 deletefcn ("deletefcn", mh, Matrix ()), |
7366 | 1302 handlevisibility ("handlevisibility", mh, "{on}|callback|off"), |
1303 hittest ("hittest", mh, true), | |
1304 interruptible ("interruptible", mh, true), | |
7404 | 1305 parent ("parent", mh, p), |
7366 | 1306 selected ("selected", mh, false), |
1307 selectionhighlight ("selectionhighlight", mh, true), | |
7404 | 1308 tag ("tag", mh), |
1309 type ("type", mh, ty), | |
7367 | 1310 userdata ("userdata", mh, Matrix ()), |
7403 | 1311 visible ("visible", mh, true), |
7404 | 1312 __modified__ ("__modified__", mh, true), |
1313 __myhandle__ (mh), | |
1314 uicontextmenu ("uicontextmenu", mh, graphics_handle ()) | |
7363 | 1315 { } |
6874 | 1316 |
1317 virtual ~base_properties (void) { } | |
1318 | |
1319 virtual std::string graphics_object_name (void) const { return "unknonwn"; } | |
1320 | |
1321 void mark_modified (void); | |
1322 | |
1323 void override_defaults (base_graphics_object& obj); | |
1324 | |
1325 // Look through DEFAULTS for properties with given CLASS_NAME, and | |
1326 // apply them to the current object with set (virtual method). | |
1327 | |
1328 void set_from_list (base_graphics_object& obj, property_list& defaults); | |
1329 | |
7363 | 1330 void insert_property (const std::string& name, property p) |
1331 { | |
1332 p.set_name (name); | |
1333 p.set_parent (__myhandle__); | |
1334 all_props[name] = p; | |
1335 } | |
1336 | |
1337 virtual void set (const caseless_str&, const octave_value&); | |
1338 | |
1339 virtual octave_value get (const caseless_str&) const; | |
1340 | |
7379 | 1341 virtual octave_value get (bool all = false) const; |
7363 | 1342 |
1343 property get_property (const caseless_str&) const; | |
1344 | |
1345 std::string get_tag (void) const { return tag.string_value (); } | |
1346 | |
1347 graphics_handle get_parent (void) const { return parent.handle_value (); } | |
1348 | |
1349 std::string get_type (void) const { return type.string_value (); } | |
1350 | |
1351 bool is_modified (void) const { return __modified__.is_on (); } | |
7251 | 1352 |
1353 graphics_handle get___myhandle__ (void) const { return __myhandle__; } | |
7366 | 1354 |
1355 std::string get_busyaction (void) const { return busyaction.current_value (); } | |
1356 | |
1357 octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); } | |
1358 | |
7435 | 1359 bool is_clipping (void) const { return clipping.is_on (); } |
7366 | 1360 std::string get_clipping (void) const { return clipping.current_value (); } |
1361 | |
7367 | 1362 void execute_createfcn (const octave_value& data = octave_value ()) const |
1363 { createfcn.execute (data); } | |
1364 | |
7366 | 1365 octave_value get_createfcn (void) const { return createfcn.get (); } |
1366 | |
7367 | 1367 void execute_deletefcn (const octave_value& data = octave_value ()) const |
1368 { deletefcn.execute (data); } | |
1369 | |
7366 | 1370 octave_value get_deletefcn (void) const { return deletefcn.get (); } |
1371 | |
1372 std::string get_handlevisibility (void) const { return handlevisibility.current_value (); } | |
1373 | |
1374 std::string get_hittest (void) const { return hittest.current_value (); } | |
1375 | |
1376 std::string get_interruptible (void) const { return interruptible.current_value (); } | |
1377 | |
1378 std::string get_selected (void) const { return selected.current_value (); } | |
1379 | |
1380 std::string get_selectionhighlight (void) const { return selectionhighlight.current_value (); } | |
1381 | |
1382 octave_value get_uicontextmenu (void) const { return uicontextmenu.get (); } | |
1383 | |
1384 octave_value get_userdata (void) const { return userdata.get (); } | |
7408 | 1385 |
1386 bool is_visible (void) const { return visible.is_on (); } | |
7366 | 1387 std::string get_visible (void) const { return visible.current_value (); } |
1388 | |
7403 | 1389 bool is_beingdeleted (void) const { return beingdeleted.is_on (); } |
1390 std::string get_beingdeleted (void) const { return beingdeleted.current_value (); } | |
1391 | |
7386 | 1392 virtual void remove_child (const graphics_handle& h); |
1393 | |
1394 virtual void adopt (const graphics_handle& h) | |
6874 | 1395 { |
1396 octave_idx_type n = children.numel (); | |
1397 children.resize (1, n+1); | |
7056 | 1398 children(n) = h.value (); |
6874 | 1399 } |
1400 | |
7419 | 1401 virtual graphics_backend get_backend (void) const; |
1402 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7524
diff
changeset
|
1403 virtual Matrix get_boundingbox (bool /*internal*/ = false) const |
7447 | 1404 { return Matrix (1, 4, 0.0); } |
1405 | |
7363 | 1406 void set_tag (const octave_value& val) { tag = val; } |
7176 | 1407 |
6874 | 1408 void set_parent (const octave_value& val); |
1409 | |
7408 | 1410 void set_modified (const octave_value& val) { __modified__ = val; } |
1411 | |
7366 | 1412 void set_busyaction (const octave_value& val) |
1413 { | |
1414 if (! error_state) | |
1415 { | |
1416 busyaction = val; | |
1417 mark_modified (); | |
1418 } | |
1419 } | |
1420 | |
1421 void set_buttondownfcn (const octave_value& val) | |
1422 { | |
1423 if (! error_state) | |
1424 { | |
1425 buttondownfcn = val; | |
1426 mark_modified (); | |
1427 } | |
1428 } | |
1429 | |
1430 void set_clipping (const octave_value& val) | |
1431 { | |
1432 if (! error_state) | |
1433 { | |
1434 clipping = val; | |
1435 mark_modified (); | |
1436 } | |
1437 } | |
1438 | |
1439 void set_createfcn (const octave_value& val) | |
1440 { | |
1441 if (! error_state) | |
1442 { | |
1443 createfcn = val; | |
1444 mark_modified (); | |
1445 } | |
1446 } | |
1447 | |
1448 void set_deletefcn (const octave_value& val) | |
1449 { | |
1450 if (! error_state) | |
1451 { | |
1452 deletefcn = val; | |
1453 mark_modified (); | |
1454 } | |
1455 } | |
1456 | |
1457 void set_handlevisibility (const octave_value& val) | |
1458 { | |
1459 if (! error_state) | |
1460 { | |
1461 handlevisibility = val; | |
1462 mark_modified (); | |
1463 } | |
1464 } | |
1465 | |
1466 void set_hittest (const octave_value& val) | |
1467 { | |
1468 if (! error_state) | |
1469 { | |
1470 hittest = val; | |
1471 mark_modified (); | |
1472 } | |
1473 } | |
1474 | |
1475 void set_interruptible (const octave_value& val) | |
1476 { | |
1477 if (! error_state) | |
1478 { | |
1479 interruptible = val; | |
1480 mark_modified (); | |
1481 } | |
1482 } | |
1483 | |
1484 void set_selected (const octave_value& val) | |
1485 { | |
1486 if (! error_state) | |
1487 { | |
1488 selected = val; | |
1489 mark_modified (); | |
1490 } | |
1491 } | |
1492 | |
1493 void set_selectionhighlight (const octave_value& val) | |
1494 { | |
1495 if (! error_state) | |
1496 { | |
1497 selectionhighlight = val; | |
1498 mark_modified (); | |
1499 } | |
1500 } | |
1501 | |
1502 void set_uicontextmenu (const octave_value& val) | |
1503 { | |
1504 if (! error_state) | |
1505 { | |
1506 uicontextmenu = val; | |
1507 mark_modified (); | |
1508 } | |
1509 } | |
1510 | |
1511 void set_userdata (const octave_value& val) | |
1512 { | |
1513 if (! error_state) | |
1514 { | |
1515 userdata = val; | |
1516 mark_modified (); | |
1517 } | |
1518 } | |
1519 | |
1520 virtual void set_visible (const octave_value& val) | |
1521 { | |
1522 if (! error_state) | |
1523 { | |
1524 visible = val; | |
1525 mark_modified (); | |
1526 } | |
1527 } | |
1528 | |
7403 | 1529 void set_beingdeleted (const octave_value& val) |
1530 { | |
1531 if (! error_state) | |
1532 { | |
1533 beingdeleted = val; | |
1534 mark_modified (); | |
1535 } | |
1536 } | |
1537 | |
7366 | 1538 |
1539 | |
6874 | 1540 void reparent (const graphics_handle& new_parent) { parent = new_parent; } |
1541 | |
7214 | 1542 // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent |
1543 // axes object. | |
1544 | |
7386 | 1545 virtual void update_axis_limits (const std::string& axis_type) const; |
7214 | 1546 |
6874 | 1547 virtual void delete_children (void); |
1548 | |
7222 | 1549 Matrix get_children (void) const { return children; } |
1550 | |
1551 // FIXME -- these functions should be generated automatically by the | |
1552 // genprops.awk script. | |
1553 // | |
1554 // EMIT_BASE_PROPERTIES_GET_FUNCTIONS | |
7363 | 1555 virtual data_property get_xdata_property (void) const |
7222 | 1556 { |
1557 error ("get: invalid property \"xdata\""); | |
1558 return data_property (); | |
1559 } | |
1560 | |
7363 | 1561 virtual data_property get_ydata_property (void) const |
7222 | 1562 { |
1563 error ("get: invalid property \"ydata\""); | |
1564 return data_property (); | |
1565 } | |
1566 | |
7363 | 1567 virtual data_property get_zdata_property (void) const |
7222 | 1568 { |
1569 error ("get: invalid property \"zdata\""); | |
1570 return data_property (); | |
1571 } | |
1572 | |
7363 | 1573 virtual data_property get_ldata_property (void) const |
7222 | 1574 { |
1575 error ("get: invalid property \"ldata\""); | |
1576 return data_property (); | |
1577 } | |
1578 | |
7363 | 1579 virtual data_property get_udata_property (void) const |
7222 | 1580 { |
1581 error ("get: invalid property \"udata\""); | |
1582 return data_property (); | |
1583 } | |
1584 | |
7363 | 1585 virtual data_property get_xldata_property (void) const |
7222 | 1586 { |
1587 error ("get: invalid property \"xldata\""); | |
1588 return data_property (); | |
1589 } | |
1590 | |
7363 | 1591 virtual data_property get_xudata_property (void) const |
7222 | 1592 { |
1593 error ("get: invalid property \"xudata\""); | |
1594 return data_property (); | |
1595 } | |
1596 | |
7363 | 1597 virtual data_property get_cdata_property (void) const |
7222 | 1598 { |
1599 error ("get: invalid property \"cdata\""); | |
1600 return data_property (); | |
1601 } | |
1602 | |
6874 | 1603 protected: |
7403 | 1604 // properties common to all objects |
1605 bool_property beingdeleted; | |
1606 radio_property busyaction; | |
1607 callback_property buttondownfcn; | |
7363 | 1608 // FIXME: use a property class for children |
6874 | 1609 Matrix children; |
7366 | 1610 bool_property clipping; |
1611 callback_property createfcn; | |
1612 callback_property deletefcn; | |
1613 radio_property handlevisibility; | |
1614 bool_property hittest; | |
1615 bool_property interruptible; | |
7403 | 1616 handle_property parent; |
7366 | 1617 bool_property selected; |
1618 bool_property selectionhighlight; | |
7403 | 1619 string_property tag; |
1620 string_property type; | |
7366 | 1621 any_property userdata; |
1622 bool_property visible; | |
7403 | 1623 // additional (octave-specific) properties |
1624 bool_property __modified__; | |
1625 graphics_handle __myhandle__; | |
1626 // FIXME: should this really be here? | |
1627 handle_property uicontextmenu; | |
7363 | 1628 |
1629 protected: | |
1630 std::map<caseless_str, property> all_props; | |
1631 | |
1632 protected: | |
1633 void insert_static_property (const std::string& name, base_property& p) | |
1634 { insert_property (name, property (&p, true)); } | |
1635 | |
1636 virtual void init (void) { } | |
6874 | 1637 }; |
1638 | |
7365 | 1639 class OCTINTERP_API base_graphics_object |
6874 | 1640 { |
1641 public: | |
1642 friend class graphics_object; | |
1643 | |
1644 base_graphics_object (void) : count (1) { } | |
1645 | |
1646 base_graphics_object (const base_graphics_object&) { } | |
1647 | |
1648 virtual ~base_graphics_object (void) { } | |
1649 | |
1650 virtual void mark_modified (void) | |
1651 { | |
7386 | 1652 if (valid_object ()) |
1653 get_properties ().mark_modified (); | |
1654 else | |
1655 error ("base_graphics_object::mark_modified: invalid graphics object"); | |
6874 | 1656 } |
1657 | |
7386 | 1658 virtual void override_defaults (base_graphics_object& obj) |
6874 | 1659 { |
7386 | 1660 if (valid_object ()) |
1661 get_properties ().override_defaults (obj); | |
1662 else | |
1663 error ("base_graphics_object::override_defaults: invalid graphics object"); | |
6874 | 1664 } |
1665 | |
7386 | 1666 virtual void set_from_list (property_list& plist) |
6874 | 1667 { |
7386 | 1668 if (valid_object ()) |
1669 get_properties ().set_from_list (*this, plist); | |
1670 else | |
1671 error ("base_graphics_object::set_from_list: invalid graphics object"); | |
6874 | 1672 } |
1673 | |
7386 | 1674 virtual void set (const caseless_str& pname, const octave_value& pval) |
6874 | 1675 { |
7386 | 1676 if (valid_object ()) |
1677 get_properties ().set (pname, pval); | |
1678 else | |
1679 error ("base_graphics_object::set: invalid graphics object"); | |
6874 | 1680 } |
1681 | |
1682 virtual void set_defaults (const std::string&) | |
1683 { | |
1684 error ("base_graphics_object::set_defaults: invalid graphics object"); | |
1685 } | |
1686 | |
7379 | 1687 virtual octave_value get (bool all = false) const |
6874 | 1688 { |
7386 | 1689 if (valid_object ()) |
1690 return get_properties ().get (all); | |
1691 else | |
1692 { | |
1693 error ("base_graphics_object::get: invalid graphics object"); | |
1694 return octave_value (); | |
1695 } | |
6874 | 1696 } |
1697 | |
7386 | 1698 virtual octave_value get (const caseless_str& pname) const |
6874 | 1699 { |
7386 | 1700 if (valid_object ()) |
1701 return get_properties ().get (pname); | |
1702 else | |
1703 { | |
1704 error ("base_graphics_object::get: invalid graphics object"); | |
1705 return octave_value (); | |
1706 } | |
6874 | 1707 } |
1708 | |
7189 | 1709 virtual octave_value get_default (const caseless_str&) const; |
6874 | 1710 |
7189 | 1711 virtual octave_value get_factory_default (const caseless_str&) const; |
6874 | 1712 |
1713 virtual octave_value get_defaults (void) const | |
1714 { | |
1715 error ("base_graphics_object::get_defaults: invalid graphics object"); | |
1716 return octave_value (); | |
1717 } | |
1718 | |
1719 virtual octave_value get_factory_defaults (void) const | |
1720 { | |
1721 error ("base_graphics_object::get_factory_defaults: invalid graphics object"); | |
1722 return octave_value (); | |
1723 } | |
1724 | |
1725 virtual graphics_handle get_parent (void) const | |
1726 { | |
7386 | 1727 if (valid_object ()) |
1728 return get_properties ().get_parent (); | |
1729 else | |
1730 { | |
1731 error ("base_graphics_object::get_parent: invalid graphics object"); | |
1732 return graphics_handle (); | |
1733 } | |
6874 | 1734 } |
1735 | |
7386 | 1736 virtual void remove_child (const graphics_handle& h) |
6874 | 1737 { |
7386 | 1738 if (valid_object ()) |
1739 get_properties ().remove_child (h); | |
1740 else | |
1741 error ("base_graphics_object::remove_child: invalid graphics object"); | |
6874 | 1742 } |
1743 | |
7386 | 1744 virtual void adopt (const graphics_handle& h) |
6874 | 1745 { |
7386 | 1746 if (valid_object ()) |
1747 get_properties ().adopt (h); | |
1748 else | |
1749 error ("base_graphics_object::adopt: invalid graphics object"); | |
6874 | 1750 } |
1751 | |
7386 | 1752 virtual void reparent (const graphics_handle& np) |
6874 | 1753 { |
7386 | 1754 if (valid_object ()) |
1755 get_properties ().reparent (np); | |
1756 else | |
1757 error ("base_graphics_object::reparent: invalid graphics object"); | |
6874 | 1758 } |
1759 | |
1760 virtual void defaults (void) const | |
1761 { | |
7386 | 1762 if (valid_object ()) |
1763 { | |
1764 std::string msg = (type () + "::defaults"); | |
1765 gripe_not_implemented (msg.c_str ()); | |
1766 } | |
1767 else | |
1768 error ("base_graphics_object::default: invalid graphics object"); | |
6874 | 1769 } |
1770 | |
1771 virtual base_properties& get_properties (void) | |
1772 { | |
1773 static base_properties properties; | |
1774 error ("base_graphics_object::get_properties: invalid graphics object"); | |
1775 return properties; | |
1776 } | |
1777 | |
7222 | 1778 virtual const base_properties& get_properties (void) const |
1779 { | |
1780 static base_properties properties; | |
1781 error ("base_graphics_object::get_properties: invalid graphics object"); | |
1782 return properties; | |
1783 } | |
1784 | |
1785 virtual void update_axis_limits (const std::string&) | |
7214 | 1786 { |
1787 error ("base_graphics_object::update_axis_limits: invalid graphics object"); | |
1788 } | |
1789 | |
6874 | 1790 virtual bool valid_object (void) const { return false; } |
1791 | |
7386 | 1792 virtual std::string type (void) const |
1793 { | |
1794 return (valid_object () ? get_properties ().graphics_object_name () | |
1795 : "unknown"); | |
1796 } | |
6874 | 1797 |
1798 bool isa (const std::string& go_name) const | |
1799 { | |
1800 return type () == go_name; | |
1801 } | |
1802 | |
7419 | 1803 virtual graphics_backend get_backend (void) const |
1804 { | |
1805 if (valid_object ()) | |
1806 return get_properties ().get_backend (); | |
1807 else | |
1808 { | |
1809 error ("base_graphics_object::get_backend: invalid graphics object"); | |
1810 return graphics_backend (); | |
1811 } | |
1812 } | |
1813 | |
6874 | 1814 protected: |
1815 // A reference count. | |
1816 int count; | |
1817 }; | |
1818 | |
7365 | 1819 class OCTINTERP_API graphics_object |
6874 | 1820 { |
1821 public: | |
1822 graphics_object (void) : rep (new base_graphics_object ()) { } | |
1823 | |
1824 graphics_object (base_graphics_object *new_rep) | |
1825 : rep (new_rep) { } | |
1826 | |
1827 graphics_object (const graphics_object& obj) | |
1828 { | |
1829 rep = obj.rep; | |
1830 rep->count++; | |
1831 } | |
1832 | |
1833 graphics_object& operator = (const graphics_object& obj) | |
1834 { | |
1835 if (rep != obj.rep) | |
1836 { | |
1837 if (--rep->count == 0) | |
1838 delete rep; | |
1839 | |
1840 rep = obj.rep; | |
1841 rep->count++; | |
1842 } | |
1843 | |
1844 return *this; | |
1845 } | |
1846 | |
1847 ~graphics_object (void) | |
1848 { | |
1849 if (--rep->count == 0) | |
1850 delete rep; | |
1851 } | |
1852 | |
1853 void mark_modified (void) { rep->mark_modified (); } | |
1854 | |
1855 void override_defaults (base_graphics_object& obj) | |
1856 { | |
1857 rep->override_defaults (obj); | |
1858 } | |
1859 | |
7214 | 1860 void set_from_list (property_list& plist) { rep->set_from_list (plist); } |
6874 | 1861 |
7189 | 1862 void set (const caseless_str& name, const octave_value& val) |
6874 | 1863 { |
1864 rep->set (name, val); | |
1865 } | |
1866 | |
1867 void set (const octave_value_list& args); | |
1868 | |
7214 | 1869 void set_defaults (const std::string& mode) { rep->set_defaults (mode); } |
1870 | |
7379 | 1871 octave_value get (bool all = false) const { return rep->get (all); } |
6874 | 1872 |
7189 | 1873 octave_value get (const caseless_str& name) const |
6874 | 1874 { |
1875 return name.compare ("default") | |
1876 ? get_defaults () | |
1877 : (name.compare ("factory") | |
1878 ? get_factory_defaults () : rep->get (name)); | |
1879 } | |
1880 | |
7189 | 1881 octave_value get_default (const caseless_str& name) const |
6874 | 1882 { |
1883 return rep->get_default (name); | |
1884 } | |
1885 | |
7189 | 1886 octave_value get_factory_default (const caseless_str& name) const |
6874 | 1887 { |
1888 return rep->get_factory_default (name); | |
1889 } | |
1890 | |
1891 octave_value get_defaults (void) const { return rep->get_defaults (); } | |
1892 | |
1893 octave_value get_factory_defaults (void) const | |
1894 { | |
1895 return rep->get_factory_defaults (); | |
1896 } | |
1897 | |
1898 graphics_handle get_parent (void) const { return rep->get_parent (); } | |
1899 | |
7214 | 1900 void remove_child (const graphics_handle& h) { rep->remove_child (h); } |
1901 | |
1902 void adopt (const graphics_handle& h) { rep->adopt (h); } | |
1903 | |
1904 void reparent (const graphics_handle& h) { rep->reparent (h); } | |
6874 | 1905 |
1906 void defaults (void) const { rep->defaults (); } | |
1907 | |
1908 bool isa (const std::string& go_name) const { return rep->isa (go_name); } | |
1909 | |
1910 base_properties& get_properties (void) { return rep->get_properties (); } | |
1911 | |
7222 | 1912 const base_properties& get_properties (void) const |
1913 { | |
1914 return rep->get_properties (); | |
1915 } | |
1916 | |
7214 | 1917 void update_axis_limits (const std::string& axis_type) |
1918 { | |
1919 rep->update_axis_limits (axis_type); | |
1920 } | |
1921 | |
6874 | 1922 bool valid_object (void) const { return rep->valid_object (); } |
1923 | |
1924 operator bool (void) const { return rep->valid_object (); } | |
1925 | |
7222 | 1926 // FIXME -- these functions should be generated automatically by the |
1927 // genprops.awk script. | |
1928 // | |
1929 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS | |
7363 | 1930 data_property get_xdata_property (void) const |
7222 | 1931 { |
1932 const base_properties& props = get_properties (); | |
7363 | 1933 return props.get_xdata_property (); |
7222 | 1934 } |
1935 | |
7363 | 1936 data_property get_ydata_property (void) const |
7222 | 1937 { |
1938 const base_properties& props = get_properties (); | |
7363 | 1939 return props.get_ydata_property (); |
7222 | 1940 } |
1941 | |
7363 | 1942 data_property get_zdata_property (void) const |
7222 | 1943 { |
1944 const base_properties& props = get_properties (); | |
7363 | 1945 return props.get_zdata_property (); |
7222 | 1946 } |
1947 | |
7363 | 1948 data_property get_ldata_property (void) const |
7222 | 1949 { |
1950 const base_properties& props = get_properties (); | |
7363 | 1951 return props.get_ldata_property (); |
7222 | 1952 } |
1953 | |
7363 | 1954 data_property get_udata_property (void) const |
7222 | 1955 { |
1956 const base_properties& props = get_properties (); | |
7363 | 1957 return props.get_udata_property (); |
7222 | 1958 } |
1959 | |
7363 | 1960 data_property get_xldata_property (void) const |
7222 | 1961 { |
1962 const base_properties& props = get_properties (); | |
7363 | 1963 return props.get_xldata_property (); |
7222 | 1964 } |
1965 | |
7363 | 1966 data_property get_xudata_property (void) const |
7222 | 1967 { |
1968 const base_properties& props = get_properties (); | |
7363 | 1969 return props.get_xudata_property (); |
7222 | 1970 } |
1971 | |
7363 | 1972 data_property get_cdata_property (void) const |
7222 | 1973 { |
1974 const base_properties& props = get_properties (); | |
7363 | 1975 return props.get_cdata_property (); |
7222 | 1976 } |
1977 | |
7419 | 1978 graphics_backend get_backend (void) const { return rep->get_backend (); } |
7408 | 1979 |
1980 private: | |
7419 | 1981 base_graphics_object *rep; |
7408 | 1982 }; |
1983 | |
1984 // --------------------------------------------------------------------- | |
1985 | |
7365 | 1986 class OCTINTERP_API root_figure : public base_graphics_object |
6874 | 1987 { |
1988 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
1989 class OCTINTERP_API properties : public base_properties |
6874 | 1990 { |
1991 public: | |
1992 // See the genprops.awk script for an explanation of the | |
1993 // properties declarations. | |
1994 | |
7363 | 1995 BEGIN_PROPERTIES(root_figure) |
1996 handle_property currentfigure S , graphics_handle () | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
1997 handle_property callbackobject Sr , graphics_handle () |
6874 | 1998 END_PROPERTIES |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
1999 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2000 private: |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2001 std::list<graphics_handle> cbo_stack; |
6874 | 2002 }; |
2003 | |
2004 private: | |
2005 properties xproperties; | |
2006 | |
2007 public: | |
2008 | |
7363 | 2009 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { } |
6874 | 2010 |
2011 ~root_figure (void) { xproperties.delete_children (); } | |
2012 | |
2013 void mark_modified (void) { } | |
2014 | |
2015 void override_defaults (base_graphics_object& obj) | |
2016 { | |
2017 // Now override with our defaults. If the default_properties | |
2018 // list includes the properties for all defaults (line, | |
2019 // surface, etc.) then we don't have to know the type of OBJ | |
2020 // here, we just call its set function and let it decide which | |
2021 // properties from the list to use. | |
2022 obj.set_from_list (default_properties); | |
2023 } | |
2024 | |
7189 | 2025 void set (const caseless_str& name, const octave_value& value) |
6874 | 2026 { |
2027 if (name.compare ("default", 7)) | |
2028 // strip "default", pass rest to function that will | |
2029 // parse the remainder and add the element to the | |
2030 // default_properties map. | |
2031 default_properties.set (name.substr (7), value); | |
2032 else | |
2033 xproperties.set (name, value); | |
2034 } | |
2035 | |
7189 | 2036 octave_value get (const caseless_str& name) const |
6874 | 2037 { |
2038 octave_value retval; | |
2039 | |
2040 if (name.compare ("default", 7)) | |
2041 return get_default (name.substr (7)); | |
2042 else if (name.compare ("factory", 7)) | |
2043 return get_factory_default (name.substr (7)); | |
2044 else | |
2045 retval = xproperties.get (name); | |
2046 | |
2047 return retval; | |
2048 } | |
2049 | |
7189 | 2050 octave_value get_default (const caseless_str& name) const |
6874 | 2051 { |
2052 octave_value retval = default_properties.lookup (name); | |
2053 | |
2054 if (retval.is_undefined ()) | |
2055 error ("get: invalid default property `%s'", name.c_str ()); | |
2056 | |
2057 return retval; | |
2058 } | |
2059 | |
7189 | 2060 octave_value get_factory_default (const caseless_str& name) const |
6874 | 2061 { |
2062 octave_value retval = factory_properties.lookup (name); | |
2063 | |
2064 if (retval.is_undefined ()) | |
2065 error ("get: invalid factory default property `%s'", name.c_str ()); | |
2066 | |
2067 return retval; | |
2068 } | |
2069 | |
2070 octave_value get_defaults (void) const | |
2071 { | |
2072 return default_properties.as_struct ("default"); | |
2073 } | |
2074 | |
2075 octave_value get_factory_defaults (void) const | |
2076 { | |
2077 return factory_properties.as_struct ("factory"); | |
2078 } | |
2079 | |
2080 base_properties& get_properties (void) { return xproperties; } | |
2081 | |
7222 | 2082 const base_properties& get_properties (void) const { return xproperties; } |
2083 | |
6874 | 2084 bool valid_object (void) const { return true; } |
2085 | |
2086 private: | |
2087 property_list default_properties; | |
2088 | |
2089 static property_list factory_properties; | |
2090 | |
2091 static property_list::plist_map_type init_factory_properties (void); | |
2092 }; | |
2093 | |
2094 // --------------------------------------------------------------------- | |
2095 | |
7365 | 2096 class OCTINTERP_API figure : public base_graphics_object |
6874 | 2097 { |
2098 public: | |
7445 | 2099 class OCTINTERP_API properties : public base_properties |
6874 | 2100 { |
2101 public: | |
7408 | 2102 void close (bool pop = true); |
2103 | |
7366 | 2104 void set_visible (const octave_value& val); |
6874 | 2105 |
7408 | 2106 graphics_backend get_backend (void) const |
2107 { | |
2108 if (! backend) | |
2109 backend = graphics_backend::default_backend (); | |
2110 | |
2111 return backend; | |
2112 } | |
2113 | |
7439 | 2114 void set_backend (const graphics_backend& b) |
2115 { | |
2116 close (false); | |
2117 backend = b; | |
2118 __backend__ = b.get_name (); | |
2119 mark_modified (); | |
2120 } | |
2121 | |
2122 void set___backend__ (const octave_value& val) | |
2123 { | |
2124 if (! error_state) | |
2125 { | |
2126 if (val.is_string ()) | |
2127 { | |
2128 std::string nm = val.string_value (); | |
2129 graphics_backend b = graphics_backend::find_backend (nm); | |
2130 if (b.get_name () != nm) | |
2131 { | |
2132 error ("figure::__backend__ : illegal backend"); | |
2133 } | |
2134 else | |
2135 { | |
2136 set_backend (b); | |
2137 mark_modified (); | |
2138 } | |
2139 } | |
2140 else | |
2141 error ("__backend__ must be a string"); | |
2142 } | |
2143 } | |
7408 | 2144 |
7447 | 2145 Matrix get_boundingbox (bool internal = false) const; |
7445 | 2146 |
6874 | 2147 // See the genprops.awk script for an explanation of the |
2148 // properties declarations. | |
2149 | |
7363 | 2150 BEGIN_PROPERTIES(figure) |
7379 | 2151 any_property __plot_stream__ h , Matrix () |
2152 bool_property __enhanced__ h , "on" | |
7405 | 2153 radio_property nextplot , "new|{add}|replace_children|replace" |
7363 | 2154 callback_property closerequestfcn , "closereq" |
2155 handle_property currentaxes S , graphics_handle () | |
2156 array_property colormap , jet_colormap () | |
7405 | 2157 radio_property paperorientation , "{portrait}|landscape|rotated" |
7363 | 2158 color_property color , color_values (1, 1, 1) |
7405 | 2159 array_property alphamap , Matrix (64, 1, 1) |
2160 string_property currentcharacter r , "" | |
2161 handle_property currentobject r , graphics_handle () | |
2162 array_property current_point r , Matrix (2, 1, 0) | |
2163 bool_property dockcontrols , "off" | |
2164 bool_property doublebuffer , "on" | |
2165 string_property filename r , "" | |
2166 bool_property integerhandle , "on" | |
2167 bool_property inverthardcopy , "off" | |
2168 callback_property keypressfcn , Matrix () | |
2169 callback_property keyreleasefcn , Matrix () | |
2170 radio_property menubar , "none|{figure}" | |
2171 double_property mincolormap , 64 | |
2172 string_property name , "" | |
2173 bool_property numbertitle , "on" | |
2174 radio_property paperunits , "{inches}|centimeters|normalized|points" | |
2175 array_property paperposition , Matrix (1, 4 , 0) | |
2176 radio_property paperpositionmode , "auto|{manual}" | |
2177 array_property papersize r , Matrix (1, 4, 0) | |
2178 radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid" | |
2179 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand" | |
2180 array_property pointershapecdata , Matrix (16, 16, 0) | |
2181 array_property pointershapehotspot , Matrix (1, 2, 0) | |
7445 | 2182 array_property position , default_figure_position () |
7405 | 2183 radio_property renderer , "{painters}|zbuffer|opengl|none" |
2184 radio_property renderermode , "{auto}|manual" | |
2185 bool_property resize , "on" | |
2186 callback_property resizefcn , Matrix () | |
2187 radio_property selectiontype , "{normal}|open|alt|extend" | |
2188 radio_property toolbar , "none|{auto}|figure" | |
2189 radio_property units , "inches|centimeters|normalized|points|{pixels}|characters" | |
2190 callback_property windowbuttondownfcn , Matrix () | |
2191 callback_property windowbuttonmotionfcn , Matrix () | |
2192 callback_property windowbuttonupfcn , Matrix () | |
2193 callback_property windowbuttonwheelfcn , Matrix () | |
2194 radio_property windowstyle , "{normal}|modal|docked" | |
2195 string_property wvisual , "" | |
2196 radio_property wvisualmode , "{auto}|manual" | |
2197 string_property xdisplay , "" | |
2198 string_property xvisual , "" | |
2199 radio_property xvisualmode , "{auto}|manual" | |
2200 callback_property buttondownfcn , Matrix () | |
7439 | 2201 string_property __backend__ s , "gnuplot" |
6874 | 2202 END_PROPERTIES |
7363 | 2203 |
2204 protected: | |
2205 void init (void) | |
2206 { | |
2207 colormap.add_constraint (dim_vector (-1, 3)); | |
7406 | 2208 alphamap.add_constraint (dim_vector (-1, 1)); |
2209 paperposition.add_constraint (dim_vector (1, 4)); | |
2210 pointershapecdata.add_constraint (dim_vector (16, 16)); | |
2211 pointershapehotspot.add_constraint (dim_vector (1, 2)); | |
2212 position.add_constraint (dim_vector (1, 4)); | |
7363 | 2213 } |
7408 | 2214 |
2215 private: | |
2216 mutable graphics_backend backend; | |
6874 | 2217 }; |
2218 | |
2219 private: | |
2220 properties xproperties; | |
2221 | |
2222 public: | |
2223 figure (const graphics_handle& mh, const graphics_handle& p) | |
2224 : base_graphics_object (), xproperties (mh, p), default_properties () | |
2225 { | |
2226 xproperties.override_defaults (*this); | |
2227 } | |
2228 | |
2229 ~figure (void) | |
2230 { | |
7386 | 2231 xproperties.delete_children (); |
6874 | 2232 xproperties.close (); |
2233 } | |
2234 | |
2235 void override_defaults (base_graphics_object& obj) | |
2236 { | |
2237 // Allow parent (root figure) to override first (properties knows how | |
2238 // to find the parent object). | |
2239 xproperties.override_defaults (obj); | |
2240 | |
2241 // Now override with our defaults. If the default_properties | |
2242 // list includes the properties for all defaults (line, | |
2243 // surface, etc.) then we don't have to know the type of OBJ | |
2244 // here, we just call its set function and let it decide which | |
2245 // properties from the list to use. | |
2246 obj.set_from_list (default_properties); | |
2247 } | |
2248 | |
7189 | 2249 void set (const caseless_str& name, const octave_value& value) |
6874 | 2250 { |
2251 if (name.compare ("default", 7)) | |
2252 // strip "default", pass rest to function that will | |
2253 // parse the remainder and add the element to the | |
2254 // default_properties map. | |
2255 default_properties.set (name.substr (7), value); | |
2256 else | |
2257 xproperties.set (name, value); | |
2258 } | |
2259 | |
7189 | 2260 octave_value get (const caseless_str& name) const |
6874 | 2261 { |
2262 octave_value retval; | |
2263 | |
2264 if (name.compare ("default", 7)) | |
2265 retval = get_default (name.substr (7)); | |
2266 else | |
2267 retval = xproperties.get (name); | |
2268 | |
2269 return retval; | |
2270 } | |
2271 | |
7189 | 2272 octave_value get_default (const caseless_str& name) const; |
6874 | 2273 |
2274 octave_value get_defaults (void) const | |
2275 { | |
2276 return default_properties.as_struct ("default"); | |
2277 } | |
2278 | |
2279 base_properties& get_properties (void) { return xproperties; } | |
2280 | |
7222 | 2281 const base_properties& get_properties (void) const { return xproperties; } |
2282 | |
6874 | 2283 bool valid_object (void) const { return true; } |
2284 | |
2285 private: | |
2286 property_list default_properties; | |
2287 }; | |
2288 | |
2289 // --------------------------------------------------------------------- | |
2290 | |
7435 | 2291 class OCTINTERP_API graphics_xform |
2292 { | |
2293 public: | |
2294 graphics_xform (void) | |
2295 : xform (xform_eye ()), xform_inv (xform_eye ()) | |
2296 { | |
2297 sx = sy = sz = "linear"; | |
2298 } | |
2299 | |
2300 graphics_xform (const Matrix& xm, const Matrix& xim, | |
2301 const scaler& x, const scaler& y, const scaler& z) | |
2302 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z) { } | |
2303 | |
2304 graphics_xform (const graphics_xform& g) | |
2305 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx), | |
2306 sy (g.sy), sz (g.sz) { } | |
2307 | |
2308 ~graphics_xform (void) { } | |
2309 | |
2310 graphics_xform& operator = (const graphics_xform& g) | |
2311 { | |
2312 xform = g.xform; | |
2313 xform_inv = g.xform_inv; | |
2314 sx = g.sx; | |
2315 sy = g.sy; | |
2316 sz = g.sz; | |
2317 | |
2318 return *this; | |
2319 } | |
2320 | |
2321 static ColumnVector xform_vector (double x, double y, double z); | |
2322 | |
2323 static Matrix xform_eye (void); | |
2324 | |
2325 ColumnVector transform (double x, double y, double z, | |
2326 bool scale = true) const; | |
2327 | |
2328 ColumnVector untransform (double x, double y, double z, | |
2329 bool scale = true) const; | |
2330 | |
2331 Matrix xscale (const Matrix& m) const { return sx.scale (m); } | |
2332 Matrix yscale (const Matrix& m) const { return sy.scale (m); } | |
2333 Matrix zscale (const Matrix& m) const { return sz.scale (m); } | |
2334 | |
2335 private: | |
2336 Matrix xform; | |
2337 Matrix xform_inv; | |
2338 scaler sx, sy, sz; | |
2339 }; | |
2340 | |
7365 | 2341 class OCTINTERP_API axes : public base_graphics_object |
6874 | 2342 { |
2343 public: | |
7445 | 2344 class OCTINTERP_API properties : public base_properties |
6874 | 2345 { |
2346 public: | |
2347 void set_defaults (base_graphics_object& obj, const std::string& mode); | |
2348 | |
2349 void remove_child (const graphics_handle& h); | |
2350 | |
2351 void delete_children (void); | |
2352 | |
7427 | 2353 const scaler& get_x_scaler (void) const { return sx; } |
2354 const scaler& get_y_scaler (void) const { return sy; } | |
2355 const scaler& get_z_scaler (void) const { return sz; } | |
2356 | |
7447 | 2357 Matrix get_boundingbox (bool internal = false) const; |
7427 | 2358 |
2359 void update_camera (void); | |
2360 void update_aspectratios (void); | |
2361 void update_transform (void) | |
2362 { | |
2363 update_aspectratios (); | |
2364 update_camera (); | |
2365 } | |
2366 | |
7435 | 2367 graphics_xform get_transform (void) const |
2368 { return graphics_xform (x_render, x_render_inv, sx, sy, sz); } | |
2369 | |
2370 Matrix get_transform_matrix (void) const { return x_render; } | |
2371 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; } | |
2372 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; } | |
2373 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; } | |
2374 Matrix get_transform_zlim (void) const { return x_zlim; } | |
2375 | |
7427 | 2376 private: |
2377 scaler sx, sy, sz; | |
2378 Matrix x_render, x_render_inv; | |
2379 Matrix x_gl_mat1, x_gl_mat2; | |
2380 Matrix x_zlim; | |
2381 | |
6874 | 2382 // See the genprops.awk script for an explanation of the |
2383 // properties declarations. | |
2384 | |
7363 | 2385 BEGIN_PROPERTIES(axes) |
7427 | 2386 array_property position , default_axes_position () |
7363 | 2387 mutable handle_property title GSO , graphics_handle () |
2388 bool_property box , "on" | |
2389 bool_property key , "off" | |
2390 bool_property keybox , "off" | |
2391 double_property keypos , 1 | |
2392 array_property colororder , default_colororder () | |
2393 array_property dataaspectratio m , Matrix (1, 3, 1.0) | |
2394 radio_property dataaspectratiomode , "{auto}|manual" | |
7379 | 2395 radio_property layer , "{bottom}|top" |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2396 row_vector_property xlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2397 row_vector_property ylim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2398 row_vector_property zlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2399 row_vector_property clim m , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2400 row_vector_property alim m , default_lim () |
7363 | 2401 radio_property xlimmode al , "{auto}|manual" |
2402 radio_property ylimmode al , "{auto}|manual" | |
2403 radio_property zlimmode al , "{auto}|manual" | |
2404 radio_property climmode al , "{auto}|manual" | |
7403 | 2405 radio_property alimmode , "{auto}|manual" |
7363 | 2406 mutable handle_property xlabel GSO , graphics_handle () |
2407 mutable handle_property ylabel GSO , graphics_handle () | |
2408 mutable handle_property zlabel GSO , graphics_handle () | |
2409 bool_property xgrid , "off" | |
2410 bool_property ygrid , "off" | |
2411 bool_property zgrid , "off" | |
2412 bool_property xminorgrid , "off" | |
2413 bool_property yminorgrid , "off" | |
2414 bool_property zminorgrid , "off" | |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2415 row_vector_property xtick m , Matrix () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2416 row_vector_property ytick m , Matrix () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2417 row_vector_property ztick m , Matrix () |
7363 | 2418 radio_property xtickmode , "{auto}|manual" |
2419 radio_property ytickmode , "{auto}|manual" | |
2420 radio_property ztickmode , "{auto}|manual" | |
7403 | 2421 bool_property xminortick , "off" |
2422 bool_property yminortick , "off" | |
2423 bool_property zminortick , "off" | |
2424 // FIXME: should be kind of string array | |
7363 | 2425 any_property xticklabel m , "" |
2426 any_property yticklabel m , "" | |
2427 any_property zticklabel m , "" | |
2428 radio_property xticklabelmode , "{auto}|manual" | |
2429 radio_property yticklabelmode , "{auto}|manual" | |
2430 radio_property zticklabelmode , "{auto}|manual" | |
7379 | 2431 color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) |
7363 | 2432 color_property xcolor , color_values (0, 0, 0) |
2433 color_property ycolor , color_values (0, 0, 0) | |
2434 color_property zcolor , color_values (0, 0, 0) | |
7427 | 2435 radio_property xscale alu , "{linear}|log" |
2436 radio_property yscale alu , "{linear}|log" | |
2437 radio_property zscale alu , "{linear}|log" | |
2438 radio_property xdir u , "{normal}|reverse" | |
2439 radio_property ydir u , "{normal}|reverse" | |
2440 radio_property zdir u , "{normal}|reverse" | |
7365 | 2441 radio_property yaxislocation , "{left}|right|zero" |
2442 radio_property xaxislocation , "{bottom}|top|zero" | |
7427 | 2443 array_property view u , Matrix () |
7363 | 2444 radio_property nextplot , "add|replace_children|{replace}" |
7427 | 2445 array_property outerposition , default_axes_outerposition () |
7379 | 2446 radio_property activepositionproperty , "{outerposition}|position" |
2447 radio_property __colorbar__ h , "{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside" | |
7403 | 2448 color_property ambientlightcolor , color_values (1, 1, 1) |
2449 array_property cameraposition m , Matrix (1, 3, 0.0) | |
2450 array_property cameratarget m , Matrix (1, 3, 0.0) | |
2451 array_property cameraupvector m , Matrix () | |
2452 double_property cameraviewangle m , 10.0 | |
2453 radio_property camerapositionmode , "{auto}|manual" | |
2454 radio_property cameratargetmode , "{auto}|manual" | |
2455 radio_property cameraupvectormode , "{auto}|manual" | |
2456 radio_property cameraviewanglemode , "{auto}|manual" | |
2457 array_property currentpoint , Matrix (2, 3, 0.0) | |
2458 radio_property drawmode , "{normal}|fast" | |
2459 radio_property fontangle , "{normal}|italic|oblique" | |
2460 string_property fontname , "Helvetica" | |
2461 double_property fontsize , 12 | |
2462 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels" | |
2463 radio_property fontweight , "{normal}|light|demi|bold" | |
7445 | 2464 radio_property gridlinestyle , "-|--|{:}|-.|none" |
7403 | 2465 // FIXME: should be kind of string array |
2466 string_property linestyleorder , "-" | |
2467 double_property linewidth , 0.5 | |
7445 | 2468 radio_property minorgridlinestyle , "-|--|{:}|-.|none" |
7403 | 2469 array_property plotboxaspectratio m , Matrix (1, 3, 1.0) |
2470 radio_property plotboxaspectratiomode , "{auto}|manual" | |
2471 radio_property projection , "{orthographic}|perpective" | |
2472 radio_property tickdir m , "{in}|out" | |
2473 radio_property tickdirmode , "{auto}|manual" | |
2474 array_property ticklength , Matrix (1, 2, 0.1) | |
2475 array_property tightinset r , Matrix (1, 4, 0.0) | |
2476 // FIXME: uicontextmenu should be moved here | |
2477 radio_property units , "{normalized}|inches|centimeters|points|pixels|characters" | |
2478 // hidden properties for transformation computation | |
2479 array_property x_viewtransform h , Matrix (4, 4, 0.0) | |
2480 array_property x_projectiontransform h , Matrix (4, 4, 0.0) | |
2481 array_property x_viewporttransform h , Matrix (4, 4, 0.0) | |
2482 array_property x_normrendertransform h , Matrix (4, 4, 0.0) | |
2483 array_property x_rendertransform h , Matrix (4, 4, 0.0) | |
7189 | 2484 END_PROPERTIES |
6874 | 2485 |
7363 | 2486 protected: |
2487 void init (void) | |
2488 { | |
2489 position.add_constraint (dim_vector (1, 4)); | |
7403 | 2490 position.add_constraint (dim_vector (0, 0)); |
7363 | 2491 outerposition.add_constraint (dim_vector (1, 4)); |
2492 colororder.add_constraint (dim_vector (-1, 3)); | |
2493 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
7403 | 2494 plotboxaspectratio.add_constraint (dim_vector (1, 3)); |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2495 xlim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2496 ylim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2497 zlim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2498 clim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2499 alim.add_constraint (2); |
7363 | 2500 xtick.add_constraint (dim_vector (1, -1)); |
2501 ytick.add_constraint (dim_vector (1, -1)); | |
2502 ztick.add_constraint (dim_vector (1, -1)); | |
2503 Matrix vw (1, 2, 0); | |
2504 vw(1) = 90; | |
2505 view = vw; | |
2506 view.add_constraint (dim_vector (1, 2)); | |
7403 | 2507 cameraposition.add_constraint (dim_vector (1, 3)); |
2508 Matrix upv (1, 3, 0.0); | |
2509 upv(2) = 1.0; | |
2510 cameraupvector = upv; | |
2511 cameraupvector.add_constraint (dim_vector (1, 3)); | |
2512 currentpoint.add_constraint (dim_vector (2, 3)); | |
2513 ticklength.add_constraint (dim_vector (1, 2)); | |
2514 tightinset.add_constraint (dim_vector (1, 4)); | |
7427 | 2515 |
2516 x_zlim.resize (1, 2); | |
2517 sx = "linear"; | |
2518 sy = "linear"; | |
2519 sz = "linear"; | |
7363 | 2520 } |
7427 | 2521 |
2522 private: | |
2523 void update_xscale (void) { sx = get_xscale (); } | |
2524 void update_yscale (void) { sy = get_yscale (); } | |
2525 void update_zscale (void) { sz = get_zscale (); } | |
2526 | |
2527 void update_view (void) { update_camera (); } | |
2528 | |
2529 void update_xdir (void) { update_camera (); } | |
2530 void update_ydir (void) { update_camera (); } | |
2531 void update_zdir (void) { update_camera (); } | |
7446 | 2532 |
2533 void magform (double x, double& a, int &b); | |
2534 | |
2535 void calc_ticks (const array_property& lims, array_property& ticks); | |
2536 | |
2537 public: | |
2538 void update_xlim (void) | |
2539 { | |
2540 if (xtickmode.is ("auto")) | |
2541 calc_ticks (xlim, xtick); | |
2542 } | |
2543 | |
2544 void update_ylim (void) | |
2545 { | |
2546 if (ytickmode.is ("auto")) | |
2547 calc_ticks (ylim, ytick); | |
2548 } | |
2549 | |
2550 void update_zlim (void) | |
2551 { | |
2552 if (ztickmode.is ("auto")) | |
2553 calc_ticks (zlim, ztick); | |
2554 } | |
2555 | |
2556 | |
6874 | 2557 }; |
2558 | |
2559 private: | |
2560 properties xproperties; | |
2561 | |
2562 public: | |
2563 axes (const graphics_handle& mh, const graphics_handle& p) | |
2564 : base_graphics_object (), xproperties (mh, p), default_properties () | |
2565 { | |
2566 xproperties.override_defaults (*this); | |
2567 } | |
2568 | |
2569 ~axes (void) { xproperties.delete_children (); } | |
2570 | |
2571 void override_defaults (base_graphics_object& obj) | |
2572 { | |
2573 // Allow parent (figure) to override first (properties knows how | |
2574 // to find the parent object). | |
2575 xproperties.override_defaults (obj); | |
2576 | |
2577 // Now override with our defaults. If the default_properties | |
2578 // list includes the properties for all defaults (line, | |
2579 // surface, etc.) then we don't have to know the type of OBJ | |
2580 // here, we just call its set function and let it decide which | |
2581 // properties from the list to use. | |
2582 obj.set_from_list (default_properties); | |
2583 } | |
2584 | |
7189 | 2585 void set (const caseless_str& name, const octave_value& value) |
6874 | 2586 { |
2587 if (name.compare ("default", 7)) | |
2588 // strip "default", pass rest to function that will | |
2589 // parse the remainder and add the element to the | |
2590 // default_properties map. | |
2591 default_properties.set (name.substr (7), value); | |
2592 else | |
2593 xproperties.set (name, value); | |
2594 } | |
2595 | |
2596 void set_defaults (const std::string& mode) | |
2597 { | |
2598 xproperties.set_defaults (*this, mode); | |
2599 } | |
2600 | |
7189 | 2601 octave_value get (const caseless_str& name) const |
6874 | 2602 { |
2603 octave_value retval; | |
2604 | |
2605 // FIXME -- finish this. | |
2606 if (name.compare ("default", 7)) | |
2607 retval = get_default (name.substr (7)); | |
2608 else | |
2609 retval = xproperties.get (name); | |
2610 | |
2611 return retval; | |
2612 } | |
2613 | |
7189 | 2614 octave_value get_default (const caseless_str& name) const; |
6874 | 2615 |
2616 octave_value get_defaults (void) const | |
2617 { | |
2618 return default_properties.as_struct ("default"); | |
2619 } | |
2620 | |
2621 base_properties& get_properties (void) { return xproperties; } | |
2622 | |
7222 | 2623 const base_properties& get_properties (void) const { return xproperties; } |
2624 | |
7214 | 2625 void update_axis_limits (const std::string& axis_type); |
2626 | |
6874 | 2627 bool valid_object (void) const { return true; } |
2628 | |
2629 private: | |
2630 property_list default_properties; | |
2631 }; | |
2632 | |
2633 // --------------------------------------------------------------------- | |
2634 | |
7365 | 2635 class OCTINTERP_API line : public base_graphics_object |
6874 | 2636 { |
2637 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2638 class OCTINTERP_API properties : public base_properties |
6874 | 2639 { |
2640 public: | |
2641 // See the genprops.awk script for an explanation of the | |
2642 // properties declarations. | |
2643 | |
7366 | 2644 // properties which are not in matlab: |
7384 | 2645 // ldata, udata, xldata, xudata, keylabel, interpreter |
7366 | 2646 |
7363 | 2647 BEGIN_PROPERTIES(line) |
2648 data_property xdata l , default_data () | |
2649 data_property ydata l , default_data () | |
2650 data_property zdata l , Matrix () | |
2651 data_property ldata l , Matrix () | |
2652 data_property udata l , Matrix () | |
2653 data_property xldata l , Matrix () | |
2654 data_property xudata l , Matrix () | |
2655 color_property color , color_values (0, 0, 0) | |
2656 radio_property linestyle , "{-}|--|:|-.|none" | |
2657 double_property linewidth , 0.5 | |
2658 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
2659 color_property markeredgecolor , "{auto}|none" | |
2660 color_property markerfacecolor , "auto|{none}" | |
2661 double_property markersize , 6 | |
2662 string_property keylabel , "" | |
7384 | 2663 radio_property interpreter , "{tex}|none|latex" |
7377 | 2664 string_property displayname , "" |
7380 | 2665 radio_property erasemode , "{normal}|none|xor|background" |
6874 | 2666 END_PROPERTIES |
2667 }; | |
2668 | |
2669 private: | |
2670 properties xproperties; | |
2671 | |
2672 public: | |
2673 line (const graphics_handle& mh, const graphics_handle& p) | |
2674 : base_graphics_object (), xproperties (mh, p) | |
2675 { | |
2676 xproperties.override_defaults (*this); | |
2677 } | |
2678 | |
2679 ~line (void) { xproperties.delete_children (); } | |
2680 | |
2681 base_properties& get_properties (void) { return xproperties; } | |
2682 | |
7222 | 2683 const base_properties& get_properties (void) const { return xproperties; } |
2684 | |
6874 | 2685 bool valid_object (void) const { return true; } |
2686 }; | |
2687 | |
2688 // --------------------------------------------------------------------- | |
2689 | |
7365 | 2690 class OCTINTERP_API text : public base_graphics_object |
6874 | 2691 { |
2692 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2693 class OCTINTERP_API properties : public base_properties |
6874 | 2694 { |
2695 public: | |
2696 // See the genprops.awk script for an explanation of the | |
2697 // properties declarations. | |
2698 | |
7363 | 2699 BEGIN_PROPERTIES(text) |
2700 string_property string , "" | |
2701 radio_property units , "{data}|pixels|normalized|inches|centimeters|points" | |
2702 array_property position , Matrix (1, 3, 0.0) | |
2703 double_property rotation , 0 | |
2704 radio_property horizontalalignment , "{left}|center|right" | |
2705 color_property color , color_values (0, 0, 0) | |
2706 string_property fontname , "Helvetica" | |
2707 double_property fontsize , 10 | |
7379 | 2708 radio_property fontangle , "{normal}|italic|oblique" |
2709 radio_property fontweight , "light|{normal}|demi|bold" | |
2710 radio_property interpreter , "{tex}|none|latex" | |
7377 | 2711 color_property backgroundcolor , "{none}" |
2712 string_property displayname , "" | |
2713 color_property edgecolor , "{none}" | |
7380 | 2714 radio_property erasemode , "{normal}|none|xor|background" |
7377 | 2715 bool_property editing , "off" |
2716 radio_property fontunits , "inches|centimeters|normalized|{points}|pixel" | |
2717 radio_property linestyle , "{-}|--|:|-.|none" | |
2718 double_property linewidth , 0.5 | |
2719 double_property margin , 1 | |
2720 radio_property verticalalignment , "top|cap|{middle}|baseline|bottom" | |
6874 | 2721 END_PROPERTIES |
2722 | |
7363 | 2723 protected: |
2724 void init (void) | |
2725 { | |
2726 position.add_constraint (dim_vector (1, 3)); | |
2727 } | |
6874 | 2728 }; |
2729 | |
2730 private: | |
2731 properties xproperties; | |
2732 | |
2733 public: | |
2734 text (const graphics_handle& mh, const graphics_handle& p) | |
2735 : base_graphics_object (), xproperties (mh, p) | |
2736 { | |
2737 xproperties.override_defaults (*this); | |
2738 } | |
2739 | |
2740 ~text (void) { xproperties.delete_children (); } | |
2741 | |
2742 base_properties& get_properties (void) { return xproperties; } | |
2743 | |
7222 | 2744 const base_properties& get_properties (void) const { return xproperties; } |
2745 | |
6874 | 2746 bool valid_object (void) const { return true; } |
2747 }; | |
2748 | |
2749 // --------------------------------------------------------------------- | |
2750 | |
7365 | 2751 class OCTINTERP_API image : public base_graphics_object |
6874 | 2752 { |
2753 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2754 class OCTINTERP_API properties : public base_properties |
6874 | 2755 { |
2756 public: | |
2757 // See the genprops.awk script for an explanation of the | |
2758 // properties declarations. | |
2759 | |
7363 | 2760 BEGIN_PROPERTIES(image) |
2761 data_property xdata l , Matrix () | |
2762 data_property ydata l , Matrix () | |
2763 data_property cdata l , Matrix () | |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7447
diff
changeset
|
2764 radio_property cdatamapping a , "{scaled}|direct" |
6874 | 2765 END_PROPERTIES |
2766 | |
7363 | 2767 protected: |
2768 void init (void) | |
2769 { | |
2770 } | |
6874 | 2771 }; |
2772 | |
2773 private: | |
2774 properties xproperties; | |
2775 | |
2776 public: | |
2777 image (const graphics_handle& mh, const graphics_handle& p) | |
2778 : base_graphics_object (), xproperties (mh, p) | |
2779 { | |
2780 xproperties.override_defaults (*this); | |
2781 } | |
2782 | |
2783 ~image (void) { xproperties.delete_children (); } | |
2784 | |
2785 base_properties& get_properties (void) { return xproperties; } | |
2786 | |
7222 | 2787 const base_properties& get_properties (void) const { return xproperties; } |
2788 | |
6874 | 2789 bool valid_object (void) const { return true; } |
2790 }; | |
2791 | |
2792 // --------------------------------------------------------------------- | |
2793 | |
7365 | 2794 class OCTINTERP_API patch : public base_graphics_object |
6874 | 2795 { |
2796 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2797 class OCTINTERP_API properties : public base_properties |
6874 | 2798 { |
2799 public: | |
2800 // See the genprops.awk script for an explanation of the | |
2801 // properties declarations. | |
2802 | |
7363 | 2803 BEGIN_PROPERTIES(patch) |
7403 | 2804 data_property xdata l , Matrix () |
7363 | 2805 data_property ydata l , Matrix () |
2806 data_property zdata l , Matrix () | |
2807 data_property cdata l , Matrix () | |
7379 | 2808 radio_property cdatamapping , "{scaled}|direct" |
7363 | 2809 array_property faces , Matrix () |
7368 | 2810 data_property facevertexalphadata , Matrix () |
2811 data_property facevertexcdata , Matrix () | |
7363 | 2812 array_property vertices , Matrix () |
7368 | 2813 array_property vertexnormals , Matrix () |
7379 | 2814 radio_property normalmode , "{auto}|manual" |
2815 color_property facecolor , "{flat}|none|interp" | |
7363 | 2816 double_property facealpha , 1.0 |
7379 | 2817 radio_property facelighting , "{flat}|none|gouraud|phong" |
2818 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) | |
7368 | 2819 double_property edgealpha , 1.0 |
7379 | 2820 radio_property edgelighting , "{none}|flat|gouraud|phong" |
2821 radio_property backfacelighting , "{reverselit}|unlit|lit" | |
7368 | 2822 double_property ambientstrength , 0.3 |
2823 double_property diffusestrength , 0.6 | |
2824 double_property specularstrength , 0.6 | |
2825 double_property specularexponent , 10.0 | |
2826 double_property specularcolorreflectance , 1.0 | |
7379 | 2827 radio_property erasemode , "{normal}|background|xor|none" |
7363 | 2828 radio_property linestyle , "{-}|--|:|-.|none" |
2829 double_property linewidth , 0.5 | |
2830 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
2831 color_property markeredgecolor , "{auto}|none" | |
2832 color_property markerfacecolor , "auto|{none}" | |
2833 double_property markersize , 6 | |
2834 string_property keylabel , "" | |
7384 | 2835 radio_property interpreter , "{tex}|none|latex" |
6874 | 2836 END_PROPERTIES |
2837 | |
7363 | 2838 protected: |
2839 void init (void) | |
2840 { | |
2841 vertices.add_constraint (dim_vector (-1, 2)); | |
2842 vertices.add_constraint (dim_vector (-1, 3)); | |
2843 } | |
6874 | 2844 }; |
2845 | |
2846 private: | |
2847 properties xproperties; | |
2848 | |
2849 public: | |
2850 patch (const graphics_handle& mh, const graphics_handle& p) | |
2851 : base_graphics_object (), xproperties (mh, p) | |
2852 { | |
2853 xproperties.override_defaults (*this); | |
2854 } | |
2855 | |
2856 ~patch (void) { xproperties.delete_children (); } | |
2857 | |
2858 base_properties& get_properties (void) { return xproperties; } | |
2859 | |
7222 | 2860 const base_properties& get_properties (void) const { return xproperties; } |
2861 | |
6874 | 2862 bool valid_object (void) const { return true; } |
2863 }; | |
2864 | |
2865 // --------------------------------------------------------------------- | |
2866 | |
7365 | 2867 class OCTINTERP_API surface : public base_graphics_object |
6874 | 2868 { |
2869 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2870 class OCTINTERP_API properties : public base_properties |
6874 | 2871 { |
2872 public: | |
2873 // See the genprops.awk script for an explanation of the | |
2874 // properties declarations. | |
2875 | |
7363 | 2876 BEGIN_PROPERTIES(surface) |
2877 data_property xdata l , Matrix () | |
2878 data_property ydata l , Matrix () | |
2879 data_property zdata l , Matrix () | |
2880 data_property cdata l , Matrix () | |
7471
86ba621332ff
Implement cdatamapping and respect to to allow correct image/imagesc rendering
David Bateman <dbateman@free.fr>
parents:
7447
diff
changeset
|
2881 radio_property cdatamapping a , "{scaled}|direct" |
7379 | 2882 color_property facecolor , "{flat}|none|interp" |
7363 | 2883 double_property facealpha , 1.0 |
7379 | 2884 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7363 | 2885 radio_property linestyle , "{-}|--|:|-.|none" |
2886 double_property linewidth , 0.5 | |
2887 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
2888 color_property markeredgecolor , "{auto}|none" | |
2889 color_property markerfacecolor , "auto|{none}" | |
2890 double_property markersize , 6 | |
2891 string_property keylabel , "" | |
7384 | 2892 radio_property interpreter , "{tex}|none|latex" |
6874 | 2893 END_PROPERTIES |
2894 | |
7363 | 2895 protected: |
2896 void init (void) | |
2897 { | |
2898 } | |
6874 | 2899 }; |
2900 | |
2901 private: | |
2902 properties xproperties; | |
2903 | |
2904 public: | |
2905 surface (const graphics_handle& mh, const graphics_handle& p) | |
2906 : base_graphics_object (), xproperties (mh, p) | |
2907 { | |
2908 xproperties.override_defaults (*this); | |
2909 } | |
2910 | |
2911 ~surface (void) { xproperties.delete_children (); } | |
2912 | |
2913 base_properties& get_properties (void) { return xproperties; } | |
2914 | |
7222 | 2915 const base_properties& get_properties (void) const { return xproperties; } |
2916 | |
6874 | 2917 bool valid_object (void) const { return true; } |
2918 }; | |
2919 | |
2920 octave_value | |
2921 get_property_from_handle (double handle, const std::string &property, | |
2922 const std::string &func); | |
2923 bool | |
2924 set_property_in_handle (double handle, const std::string &property, | |
2925 const octave_value &arg, const std::string &func); | |
2926 | |
2927 // --------------------------------------------------------------------- | |
2928 | |
7365 | 2929 class OCTINTERP_API gh_manager |
6874 | 2930 { |
2931 protected: | |
2932 | |
2933 gh_manager (void); | |
2934 | |
2935 public: | |
2936 | |
2937 static bool instance_ok (void) | |
2938 { | |
2939 bool retval = true; | |
2940 | |
2941 if (! instance) | |
2942 instance = new gh_manager (); | |
2943 | |
2944 if (! instance) | |
2945 { | |
2946 ::error ("unable to create gh_manager!"); | |
2947 | |
2948 retval = false; | |
2949 } | |
2950 | |
2951 return retval; | |
2952 } | |
2953 | |
2954 static void free (const graphics_handle& h) | |
2955 { | |
2956 if (instance_ok ()) | |
2957 instance->do_free (h); | |
2958 } | |
2959 | |
2960 static graphics_handle lookup (double val) | |
2961 { | |
2962 return instance_ok () ? instance->do_lookup (val) : graphics_handle (); | |
2963 } | |
2964 | |
2965 static graphics_object get_object (const graphics_handle& h) | |
2966 { | |
2967 return instance_ok () ? instance->do_get_object (h) : graphics_object (); | |
2968 } | |
2969 | |
2970 static graphics_handle | |
2971 make_graphics_handle (const std::string& go_name, | |
7370 | 2972 const graphics_handle& parent, bool do_createfcn = true) |
6874 | 2973 { |
2974 return instance_ok () | |
7370 | 2975 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn) |
6874 | 2976 : graphics_handle (); |
2977 } | |
2978 | |
2979 static graphics_handle make_figure_handle (double val) | |
2980 { | |
2981 return instance_ok () | |
2982 ? instance->do_make_figure_handle (val) : graphics_handle (); | |
2983 } | |
2984 | |
2985 static void push_figure (const graphics_handle& h) | |
2986 { | |
2987 if (instance_ok ()) | |
2988 instance->do_push_figure (h); | |
2989 } | |
2990 | |
2991 static void pop_figure (const graphics_handle& h) | |
2992 { | |
2993 if (instance_ok ()) | |
2994 instance->do_pop_figure (h); | |
2995 } | |
2996 | |
2997 static graphics_handle current_figure (void) | |
2998 { | |
2999 return instance_ok () | |
3000 ? instance->do_current_figure () : graphics_handle (); | |
3001 } | |
3002 | |
3003 static Matrix handle_list (void) | |
3004 { | |
3005 return instance_ok () ? instance->do_handle_list () : Matrix (); | |
3006 } | |
3007 | |
3008 static Matrix figure_handle_list (void) | |
3009 { | |
3010 return instance_ok () ? instance->do_figure_handle_list () : Matrix (); | |
3011 } | |
3012 | |
3013 private: | |
3014 | |
3015 static gh_manager *instance; | |
3016 | |
3017 typedef std::map<graphics_handle, graphics_object>::iterator iterator; | |
3018 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator; | |
3019 | |
3020 typedef std::set<graphics_handle>::iterator free_list_iterator; | |
3021 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator; | |
3022 | |
3023 typedef std::list<graphics_handle>::iterator figure_list_iterator; | |
3024 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator; | |
3025 | |
3026 // A map of handles to graphics objects. | |
3027 std::map<graphics_handle, graphics_object> handle_map; | |
3028 | |
3029 // The available graphics handles. | |
3030 std::set<graphics_handle> handle_free_list; | |
3031 | |
3032 // The next handle available if handle_free_list is empty. | |
7286 | 3033 double next_handle; |
6874 | 3034 |
3035 // The allocated figure handles. Top of the stack is most recently | |
3036 // created. | |
3037 std::list<graphics_handle> figure_list; | |
3038 | |
3039 graphics_handle get_handle (const std::string& go_name); | |
3040 | |
3041 void do_free (const graphics_handle& h); | |
3042 | |
3043 graphics_handle do_lookup (double val) | |
3044 { | |
7363 | 3045 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val)); |
6874 | 3046 |
3047 return (p != handle_map.end ()) ? p->first : graphics_handle (); | |
3048 } | |
3049 | |
3050 graphics_object do_get_object (const graphics_handle& h) | |
3051 { | |
7379 | 3052 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); |
6874 | 3053 |
3054 return (p != handle_map.end ()) ? p->second : graphics_object (); | |
3055 } | |
3056 | |
3057 graphics_handle do_make_graphics_handle (const std::string& go_name, | |
7370 | 3058 const graphics_handle& p, bool do_createfcn); |
6874 | 3059 |
3060 graphics_handle do_make_figure_handle (double val); | |
3061 | |
3062 Matrix do_handle_list (void) | |
3063 { | |
3064 Matrix retval (1, handle_map.size ()); | |
3065 octave_idx_type i = 0; | |
3066 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) | |
7056 | 3067 { |
3068 graphics_handle h = p->first; | |
3069 retval(i++) = h.value (); | |
3070 } | |
6874 | 3071 return retval; |
3072 } | |
3073 | |
3074 Matrix do_figure_handle_list (void) | |
3075 { | |
3076 Matrix retval (1, figure_list.size ()); | |
3077 octave_idx_type i = 0; | |
3078 for (const_figure_list_iterator p = figure_list.begin (); | |
3079 p != figure_list.end (); | |
3080 p++) | |
7056 | 3081 { |
3082 graphics_handle h = *p; | |
3083 retval(i++) = h.value (); | |
3084 } | |
6874 | 3085 return retval; |
3086 } | |
3087 | |
3088 void do_push_figure (const graphics_handle& h); | |
3089 | |
3090 void do_pop_figure (const graphics_handle& h); | |
3091 | |
3092 graphics_handle do_current_figure (void) const | |
3093 { | |
3094 return figure_list.empty () ? graphics_handle () : figure_list.front (); | |
3095 } | |
3096 }; | |
3097 | |
3098 | |
3099 // This function is NOT equivalent to the scripting language function gcf. | |
7365 | 3100 OCTINTERP_API graphics_handle gcf (void); |
6874 | 3101 |
3102 // This function is NOT equivalent to the scripting language function gca. | |
7365 | 3103 OCTINTERP_API graphics_handle gca (void); |
6874 | 3104 |
3105 #endif | |
3106 | |
3107 /* | |
3108 ;;; Local Variables: *** | |
3109 ;;; mode: C++ *** | |
3110 ;;; End: *** | |
3111 */ |