annotate src/graphics.h.in @ 6874:94bda6abc224

[project @ 2007-09-06 21:34:24 by jwe]
author jwe
date Thu, 06 Sep 2007 21:34:24 +0000
parents
children b2b7526a5772
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1 /*
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
2
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
3 Copyright (C) 2007 John W. Eaton
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
4
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
6
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
10 later version.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
11
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
15 for more details.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
16
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
18 along with Octave; see the file COPYING. If not, write to the Free
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
20 02110-1301, USA.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
21
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
22 */
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
23
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
24 #if !defined (graphics_h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
25 #define graphics_h 1
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
26
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
27 #ifdef HAVE_CONFIG_H
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
28 #include <config.h>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
29 #endif
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
30
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
31 #include <cctype>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
32
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
33 #include <algorithm>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
34 #include <list>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
35 #include <map>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
36 #include <set>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
37 #include <string>
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
38
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
39 #include "oct-map.h"
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
40 #include "ov.h"
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
41
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
42 class
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
43 radio_values
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
44 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
45 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
46 radio_values (const std::string& opt_string = std::string ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
47 radio_values (const radio_values& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
48 : default_val (a.default_val), possible_vals (a.possible_vals) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
49
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
50 radio_values& operator = (const radio_values& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
51 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
52 if (&a != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
53 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
54 default_val = a.default_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
55 possible_vals = a.possible_vals;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
56 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
57
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
58 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
59 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
60
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
61 std::string default_value (void) const { return default_val; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
62
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
63 std::set<std::string> possible_values (void) const { return possible_vals; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
64
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
65 bool validate (const std::string& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
66 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
67 bool retval = true;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
68
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
69 if (possible_vals.find (val) == possible_vals.end ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
70 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
71 error ("invalid value = %s", val.c_str ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
72 retval = false;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
73 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
74
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
75 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
76 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
77
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
78 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
79 // Might also want to cache
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
80 std::string default_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
81 std::set<std::string> possible_vals;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
82 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
83
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
84 class
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
85 radio_property
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
86 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
87 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
88 radio_property (const radio_values& v)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
89 : vals (v), current_val (v.default_value ()) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
90
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
91 radio_property (const radio_values& v, const std::string& initial_value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
92 : vals (v), current_val (initial_value) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
93
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
94 radio_property (const radio_property& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
95 : vals (a.vals), current_val (a.current_val) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
96
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
97 radio_property& operator = (const radio_property& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
98 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
99 if (&a != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
100 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
101 vals = a.vals;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
102 current_val = a.current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
103 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
104
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
105 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
106 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
107
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
108 radio_property& operator = (const std::string& newval)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
109 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
110 if (vals.validate (newval))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
111 current_val = newval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
112
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
113 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
114 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
115
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
116 const std::string& current_value (void) const { return current_val; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
117
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
118 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
119 radio_values vals;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
120 std::string current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
121 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
122
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
123 class
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
124 color_values
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
125 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
126 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
127 color_values (double r = 0, double g = 0, double b = 1)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
128 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
129 xrgb[0] = r;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
130 xrgb[1] = g;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
131 xrgb[2] = b;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
132
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
133 validate ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
134 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
135
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
136 color_values (std::string str)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
137 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
138 if (! str2rgb (str))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
139 error ("invalid color specification");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
140 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
141
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
142 color_values (const color_values& c)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
143 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
144 xrgb[0] = c.xrgb[0];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
145 xrgb[1] = c.xrgb[1];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
146 xrgb[2] = c.xrgb[2];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
147 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
148
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
149 color_values& operator = (const color_values& c)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
150 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
151 if (&c != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
152 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
153 xrgb[0] = c.xrgb[0];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
154 xrgb[1] = c.xrgb[1];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
155 xrgb[2] = c.xrgb[2];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
156
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
157 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
158
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
159 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
160 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
161
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
162 const double* rgb (void) const { return xrgb; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
163
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
164 void validate (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
165 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
166 for (int i = 0; i < 3; i++)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
167 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
168 if (xrgb[i] < 0 || xrgb[i] > 1)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
169 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
170 error ("invalid RGB color specification");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
171 break;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
172 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
173 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
174 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
175
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
176 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
177 double xrgb[3];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
178
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
179 bool str2rgb (std::string str);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
180 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
181
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
182
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
183 class
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
184 color_property
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
185 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
186 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
187 color_property (const color_values& c = color_values (),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
188 const radio_values& v = radio_values ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
189 : current_type (color_t), color_val (c), radio_val (v),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
190 current_val (v.default_value ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
191 { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
192
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
193 color_property (const radio_values& v)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
194 : current_type (radio_t), color_val (color_values ()), radio_val (v),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
195 current_val (v.default_value ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
196 { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
197
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
198 color_property (const radio_values& v, const std::string& initial_value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
199 : current_type (radio_t), color_val (color_values ()), radio_val (v),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
200 current_val (initial_value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
201 { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
202
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
203 color_property (const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
204
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
205 operator octave_value (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
206 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
207 if (current_type == color_t)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
208 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
209 Matrix retval (1, 3);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
210 const double *xrgb = color_val.rgb ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
211
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
212 for (int i = 0; i < 3 ; i++)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
213 retval(i) = xrgb[i];
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
214
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
215 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
216 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
217
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
218 return current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
219 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
220
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
221 color_property& operator = (const color_property& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
222 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
223 if (&a != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
224 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
225 current_type = a.current_type;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
226 color_val = a.color_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
227 radio_val = a.radio_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
228 current_val = a.current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
229 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
230
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
231 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
232 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
233
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
234 color_property& operator = (const std::string& newval)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
235 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
236 if (radio_val.validate (newval))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
237 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
238 current_val = newval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
239 current_type = radio_t;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
240 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
241
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
242 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
243 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
244
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
245 color_property& operator = (const color_values& newval)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
246 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
247 color_val = newval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
248 current_type = color_t;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
249
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
250 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
251 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
252
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
253 color_property& operator = (const octave_value& newval);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
254
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
255 bool is_rgb (void) const { return (current_type == color_t); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
256
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
257 bool is_radio (void) const { return (current_type == radio_t); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
258
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
259 const double* rgb (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
260 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
261 if (current_type != color_t)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
262 error ("color has no rgb value");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
263
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
264 return color_val.rgb ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
265 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
266
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
267 const std::string& current_value (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
268 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
269 if (current_type != radio_t)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
270 error ("color has no radio value");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
271
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
272 return current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
273 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
274
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
275 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
276 enum current_enum { color_t, radio_t } current_type;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
277 color_values color_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
278 radio_values radio_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
279 std::string current_val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
280 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
281
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
282 class
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
283 colormap_property
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
284 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
285 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
286 colormap_property (const Matrix& m = Matrix ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
287 : cmap (m)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
288 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
289 if (cmap.is_empty ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
290 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
291 cmap = Matrix (64, 3);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
292
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
293 for (octave_idx_type i = 0; i < 64; i++)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
294 cmap(i,0) = cmap(i,1) = cmap(i,2) = i / 64.0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
295 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
296
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
297 validate ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
298 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
299
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
300 colormap_property (const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
301 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
302 cmap = val.matrix_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
303
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
304 validate ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
305 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
306
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
307 void validate (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
308 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
309 if (error_state || cmap.columns () != 3)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
310 error ("invalid colormap specification");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
311 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
312
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
313 operator octave_value (void) const { return cmap; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
314
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
315 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
316 Matrix cmap;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
317 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
318
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
319 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
320
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
321 class property_name : public std::string
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
322 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
323 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
324 typedef std::string::iterator iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
325 typedef std::string::const_iterator const_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
326
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
327 property_name (void) : std::string () { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
328 property_name (const std::string& s) : std::string (s) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
329 property_name (const char *s) : std::string (s) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
330
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
331 property_name (const property_name& name) : std::string (name) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
332
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
333 property_name& operator = (const property_name& pname)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
334 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
335 std::string::operator = (pname);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
336 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
337 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
338
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
339 operator std::string (void) const { return *this; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
340
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
341 // Case-insensitive comparison.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
342 bool compare (const std::string& s, size_t limit = NPOS) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
343 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
344 const_iterator p1 = begin ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
345 const_iterator p2 = s.begin ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
346
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
347 size_t k = 0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
348
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
349 while (p1 != end () && p2 != s.end () && k++ < limit)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
350 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
351 if (std::tolower (*p1) != std::tolower (*p2))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
352 return false;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
353
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
354 *p1++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
355 *p2++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
356 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
357
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
358 return (limit == NPOS) ? size () == s.size () : k == limit;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
359 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
360 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
361
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
362 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
363
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
364 class property_list
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
365 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
366 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
367 typedef std::map<std::string, octave_value> pval_map_type;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
368 typedef std::map<std::string, pval_map_type> plist_map_type;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
369
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
370 typedef pval_map_type::iterator pval_map_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
371 typedef pval_map_type::const_iterator pval_map_const_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
372
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
373 typedef plist_map_type::iterator plist_map_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
374 typedef plist_map_type::const_iterator plist_map_const_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
375
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
376 property_list (const plist_map_type& m = plist_map_type ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
377 : plist_map (m) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
378
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
379 ~property_list (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
380
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
381 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
382
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
383 octave_value lookup (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
384
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
385 plist_map_iterator begin (void) { return plist_map.begin (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
386 plist_map_const_iterator begin (void) const { return plist_map.begin (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
387
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
388 plist_map_iterator end (void) { return plist_map.end (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
389 plist_map_const_iterator end (void) const { return plist_map.end (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
390
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
391 plist_map_iterator find (const std::string& go_name)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
392 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
393 return plist_map.find (go_name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
394 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
395
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
396 plist_map_const_iterator find (const std::string& go_name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
397 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
398 return plist_map.find (go_name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
399 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
400
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
401 Octave_map as_struct (const std::string& prefix_arg) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
402
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
403 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
404 plist_map_type plist_map;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
405 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
406
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
407 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
408
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
409 class graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
410 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
411 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
412 graphics_handle (void) : val (octave_NaN) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
413
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
414 graphics_handle (const octave_value& a);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
415
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
416 graphics_handle (int a) : val (a) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
417
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
418 graphics_handle (double a) : val (a) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
419
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
420 graphics_handle (const graphics_handle& a) : val (a.val) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
421
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
422 graphics_handle& operator = (const graphics_handle& a)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
423 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
424 if (&a != this)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
425 val = a.val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
426
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
427 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
428 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
429
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
430 ~graphics_handle (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
431
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
432 operator double (void) const { return val; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
433
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
434 double value (void) const { return val; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
435
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
436 octave_value as_octave_value (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
437 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
438 return ok () ? octave_value (val) : octave_value (Matrix ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
439 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
440
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
441 graphics_handle operator ++ (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
442 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
443 ++val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
444 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
445 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
446
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
447 graphics_handle operator ++ (int)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
448 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
449 graphics_handle h = *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
450 ++val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
451 return h;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
452 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
453
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
454 graphics_handle operator -- (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
455 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
456 --val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
457 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
458 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
459
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
460 graphics_handle operator -- (int)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
461 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
462 graphics_handle h = *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
463 --val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
464 return h;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
465 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
466
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
467 bool ok (void) const { return ! xisnan (val); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
468
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
469 operator bool () const { return ok (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
470
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
471 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
472 double val;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
473 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
474
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
475 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
476 operator == (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
477 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
478 return a.value () == b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
479 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
480
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
481 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
482 operator != (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
483 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
484 return a.value () != b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
485 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
486
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
487 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
488 operator < (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
489 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
490 return a.value () < b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
491 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
492
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
493 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
494 operator <= (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
495 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
496 return a.value () <= b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
497 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
498
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
499 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
500 operator >= (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
501 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
502 return a.value () >= b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
503 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
504
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
505 inline bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
506 operator > (const graphics_handle& a, const graphics_handle& b)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
507 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
508 return a.value () > b.value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
509 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
510
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
511 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
512
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
513 class base_graphics_object;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
514
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
515 class base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
516 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
517 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
518 base_properties (const std::string& t = "unknown",
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
519 const graphics_handle& mh = graphics_handle (),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
520 const graphics_handle& p = graphics_handle ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
521 : type (t), __modified__ (true), __myhandle__ (mh), parent (p),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
522 children () { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
523
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
524 virtual ~base_properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
525
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
526 virtual std::string graphics_object_name (void) const { return "unknonwn"; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
527
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
528 void mark_modified (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
529
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
530 void override_defaults (base_graphics_object& obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
531
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
532 // Look through DEFAULTS for properties with given CLASS_NAME, and
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
533 // apply them to the current object with set (virtual method).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
534
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
535 void set_from_list (base_graphics_object& obj, property_list& defaults);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
536
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
537 virtual void set (const property_name&, const octave_value&) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
538
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
539 graphics_handle get_parent (void) const { return parent; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
540
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
541 void remove_child (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
542
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
543 void adopt (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
544 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
545 octave_idx_type n = children.numel ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
546 children.resize (1, n+1);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
547 children(n) = h;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
548 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
549
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
550 void set_parent (const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
551
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
552 void reparent (const graphics_handle& new_parent) { parent = new_parent; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
553
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
554 virtual void delete_children (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
555
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
556 protected:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
557 std::string type;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
558 bool __modified__;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
559 graphics_handle __myhandle__;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
560 graphics_handle parent;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
561 Matrix children;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
562 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
563
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
564 class base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
565 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
566 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
567 friend class graphics_object;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
568
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
569 base_graphics_object (void) : count (1) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
570
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
571 base_graphics_object (const base_graphics_object&) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
572
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
573 virtual ~base_graphics_object (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
574
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
575 virtual void mark_modified (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
576 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
577 error ("base_graphics_object::mark_modified: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
578 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
579
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
580 virtual void override_defaults (base_graphics_object&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
581 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
582 error ("base_graphics_object::override_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
583 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
584
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
585 virtual void set_from_list (property_list&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
586 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
587 error ("base_graphics_object::set_from_list: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
588 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
589
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
590 virtual void set (const property_name&, const octave_value&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
591 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
592 error ("base_graphics_object::set: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
593 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
594
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
595 virtual void set_defaults (const std::string&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
596 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
597 error ("base_graphics_object::set_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
598 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
599
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
600 virtual octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
601 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
602 error ("base_graphics_object::get: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
603 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
604 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
605
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
606 virtual octave_value get (const property_name&) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
607 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
608 error ("base_graphics_object::get: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
609 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
610 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
611
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
612 virtual octave_value get_default (const property_name&) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
613
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
614 virtual octave_value get_factory_default (const property_name&) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
615
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
616 virtual octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
617 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
618 error ("base_graphics_object::get_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
619 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
620 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
621
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
622 virtual octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
623 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
624 error ("base_graphics_object::get_factory_defaults: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
625 return octave_value ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
626 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
627
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
628 virtual graphics_handle get_parent (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
629 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
630 error ("base_graphics_object::get_parent: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
631 return graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
632 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
633
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
634 virtual void remove_child (const graphics_handle&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
635 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
636 error ("base_graphics_object::remove_child: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
637 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
638
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
639 virtual void adopt (const graphics_handle&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
640 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
641 error ("base_graphics_object::adopt: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
642 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
643
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
644 virtual void reparent (const graphics_handle&)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
645 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
646 error ("base_graphics_object::reparent: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
647 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
648
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
649 virtual void defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
650 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
651 error ("base_graphics_object::default: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
652 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
653
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
654 virtual base_properties& get_properties (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
655 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
656 static base_properties properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
657 error ("base_graphics_object::get_properties: invalid graphics object");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
658 return properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
659 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
660
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
661 virtual bool valid_object (void) const { return false; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
662
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
663 virtual std::string type (void) const { return "unknown"; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
664
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
665 bool isa (const std::string& go_name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
666 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
667 return type () == go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
668 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
669
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
670 protected:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
671 // A reference count.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
672 int count;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
673 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
674
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
675 class graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
676 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
677 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
678 graphics_object (void) : rep (new base_graphics_object ()) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
679
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
680 graphics_object (base_graphics_object *new_rep)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
681 : rep (new_rep) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
682
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
683 graphics_object (const graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
684 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
685 rep = obj.rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
686 rep->count++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
687 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
688
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
689 graphics_object& operator = (const graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
690 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
691 if (rep != obj.rep)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
692 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
693 if (--rep->count == 0)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
694 delete rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
695
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
696 rep = obj.rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
697 rep->count++;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
698 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
699
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
700 return *this;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
701 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
702
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
703 ~graphics_object (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
704 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
705 if (--rep->count == 0)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
706 delete rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
707 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
708
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
709 void mark_modified (void) { rep->mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
710
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
711 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
712 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
713 rep->override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
714 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
715
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
716 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
717 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
718 rep->set_from_list (plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
719 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
720
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
721 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
722 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
723 rep->set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
724 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
725
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
726 void set (const octave_value_list& args);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
727
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
728 void set_defaults (const std::string& mode)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
729 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
730 rep->set_defaults (mode);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
731 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
732
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
733 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
734 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
735 return rep->get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
736 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
737
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
738 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
739 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
740 return name.compare ("default")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
741 ? get_defaults ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
742 : (name.compare ("factory")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
743 ? get_factory_defaults () : rep->get (name));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
744 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
745
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
746 octave_value get_default (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
747 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
748 return rep->get_default (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
749 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
750
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
751 octave_value get_factory_default (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
752 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
753 return rep->get_factory_default (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
754 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
755
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
756 octave_value get_defaults (void) const { return rep->get_defaults (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
757
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
758 octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
759 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
760 return rep->get_factory_defaults ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
761 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
762
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
763 graphics_handle get_parent (void) const { return rep->get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
764
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
765 void remove_child (const graphics_handle& h) { return rep->remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
766
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
767 void adopt (const graphics_handle& h) { return rep->adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
768
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
769 void reparent (const graphics_handle& h) { return rep->reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
770
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
771 void defaults (void) const { rep->defaults (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
772
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
773 bool isa (const std::string& go_name) const { return rep->isa (go_name); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
774
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
775 base_properties& get_properties (void) { return rep->get_properties (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
776
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
777 bool valid_object (void) const { return rep->valid_object (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
778
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
779 operator bool (void) const { return rep->valid_object (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
780
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
781 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
782 base_graphics_object *rep;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
783 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
784
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
785 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
786
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
787 class root_figure : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
788 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
789 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
790 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
791 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
792 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
793 properties (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
794 : base_properties ("root figure", 0, graphics_handle ()),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
795 currentfigure (),
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
796 visible ("on")
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
797 { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
798
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
799 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
800
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
801 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
802
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
803 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
804
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
805 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
806
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
807 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
808
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
809 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
810 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
811
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
812 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
813 graphics_handle currentfigure S
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
814 octave_value visible
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
815 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
816
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
817 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
818 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
819
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
820 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
821 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
822
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
823 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
824
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
825 root_figure (void) : xproperties (), default_properties () { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
826
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
827 ~root_figure (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
828
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
829 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
830
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
831 void mark_modified (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
832
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
833 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
834 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
835 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
836 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
837 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
838 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
839 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
840 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
841 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
842
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
843 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
844 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
845 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
846 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
847
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
848 void set (const property_name& name, const octave_value& value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
849 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
850 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
851 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
852 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
853 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
854 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
855 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
856 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
857 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
858
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
859 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
860 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
861 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
862 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
863
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
864 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
865 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
866 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
867
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
868 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
869 return get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
870 else if (name.compare ("factory", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
871 return get_factory_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
872 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
873 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
874
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
875 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
876 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
877
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
878 octave_value get_default (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
879 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
880 octave_value retval = default_properties.lookup (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
881
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
882 if (retval.is_undefined ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
883 error ("get: invalid default property `%s'", name.c_str ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
884
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
885 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
886 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
887
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
888 octave_value get_factory_default (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
889 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
890 octave_value retval = factory_properties.lookup (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
891
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
892 if (retval.is_undefined ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
893 error ("get: invalid factory default property `%s'", name.c_str ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
894
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
895 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
896 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
897
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
898 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
899 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
900 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
901 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
902
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
903 octave_value get_factory_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
904 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
905 return factory_properties.as_struct ("factory");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
906 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
907
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
908 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
909
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
910 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
911
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
912 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
913
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
914 void reparent (const graphics_handle& np) { xproperties.reparent (np); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
915
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
916 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
917
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
918 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
919
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
920 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
921 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
922
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
923 static property_list factory_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
924
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
925 static property_list::plist_map_type init_factory_properties (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
926 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
927
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
928 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
929
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
930 class figure : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
931 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
932 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
933 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
934 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
935 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
936 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
937
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
938 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
939
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
940 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
941
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
942 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
943
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
944 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
945
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
946 void close (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
947
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
948 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
949
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
950 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
951
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
952 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
953 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
954
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
955 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
956 octave_value __plot_stream__
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
957 octave_value nextplot
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
958 octave_value closerequestfcn
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
959 graphics_handle currentaxes S
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
960 colormap_property colormap
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
961 octave_value visible S
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
962 octave_value paperorientation
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
963 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
964
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
965 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
966 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
967
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
968 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
969 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
970
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
971 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
972 figure (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
973 : base_graphics_object (), xproperties (mh, p), default_properties ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
974 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
975 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
976 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
977
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
978 ~figure (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
979 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
980 xproperties.delete_children ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
981 xproperties.close ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
982 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
983
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
984 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
985
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
986 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
987
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
988 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
989 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
990 // Allow parent (root figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
991 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
992 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
993
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
994 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
995 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
996 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
997 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
998 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
999 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1000 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1001
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1002 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1003 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1004 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1005 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1006
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1007 void set (const property_name& name, const octave_value& value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1008 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1009 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1010 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1011 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1012 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1013 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1014 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1015 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1016 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1017
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1018 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1019 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1020 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1021 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1022
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1023 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1024 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1025 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1026
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1027 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1028 retval = get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1029 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1030 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1031
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1032 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1033 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1034
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1035 octave_value get_default (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1036
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1037 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1038 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1039 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1040 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1041
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1042 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1043
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1044 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1045
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1046 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1047
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1048 void reparent (const graphics_handle& np) { xproperties.reparent (np); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1049
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1050 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1051
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1052 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1053
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1054 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1055 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1056 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1057
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1058 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1059
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1060 class axes : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1061 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1062 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1063 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1064 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1065 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1066 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1067
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1068 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1069
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1070 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1071
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1072 void set_defaults (base_graphics_object& obj, const std::string& mode);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1073
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1074 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1075
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1076 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1077
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1078 void remove_child (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1079
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1080 void delete_children (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1081
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1082 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1083
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1084 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1085
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1086 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1087 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1088
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1089 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1090 octave_value position
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1091 mutable graphics_handle title GSO
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1092 octave_value box
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1093 octave_value key
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1094 octave_value keybox
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1095 octave_value keypos
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1096 octave_value dataaspectratio m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1097 octave_value dataaspectratiomode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1098 octave_value xlim m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1099 octave_value ylim m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1100 octave_value zlim m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1101 octave_value clim m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1102 octave_value xlimmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1103 octave_value ylimmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1104 octave_value zlimmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1105 octave_value climmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1106 mutable graphics_handle xlabel GSO
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1107 mutable graphics_handle ylabel GSO
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1108 mutable graphics_handle zlabel GSO
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1109 octave_value xgrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1110 octave_value ygrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1111 octave_value zgrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1112 octave_value xminorgrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1113 octave_value yminorgrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1114 octave_value zminorgrid
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1115 octave_value xtick m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1116 octave_value ytick m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1117 octave_value ztick m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1118 octave_value xtickmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1119 octave_value ytickmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1120 octave_value ztickmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1121 octave_value xticklabel m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1122 octave_value yticklabel m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1123 octave_value zticklabel m
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1124 octave_value xticklabelmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1125 octave_value yticklabelmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1126 octave_value zticklabelmode
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1127 octave_value xscale
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1128 octave_value yscale
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1129 octave_value zscale
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1130 octave_value xdir
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1131 octave_value ydir
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1132 octave_value zdir
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1133 octave_value xaxislocation
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1134 octave_value yaxislocation
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1135 octave_value view
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1136 octave_value visible
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1137 octave_value nextplot
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1138 octave_value outerposition
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1139 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1140
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1141 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1142 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1143
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1144 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1145 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1146
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1147 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1148 axes (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1149 : base_graphics_object (), xproperties (mh, p), default_properties ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1150 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1151 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1152 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1153
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1154 ~axes (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1155
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1156 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1157
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1158 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1159
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1160 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1161 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1162 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1163 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1164 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1165
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1166 // Now override with our defaults. If the default_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1167 // list includes the properties for all defaults (line,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1168 // surface, etc.) then we don't have to know the type of OBJ
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1169 // here, we just call its set function and let it decide which
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1170 // properties from the list to use.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1171 obj.set_from_list (default_properties);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1172 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1173
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1174 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1175 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1176 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1177 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1178
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1179 void set (const property_name& name, const octave_value& value)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1180 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1181 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1182 // strip "default", pass rest to function that will
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1183 // parse the remainder and add the element to the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1184 // default_properties map.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1185 default_properties.set (name.substr (7), value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1186 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1187 xproperties.set (name, value);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1188 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1189
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1190 void set_defaults (const std::string& mode)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1191 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1192 xproperties.set_defaults (*this, mode);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1193 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1194
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1195 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1196 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1197 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1198 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1199
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1200 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1201 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1202 octave_value retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1203
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1204 // FIXME -- finish this.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1205 if (name.compare ("default", 7))
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1206 retval = get_default (name.substr (7));
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1207 else
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1208 retval = xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1209
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1210 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1211 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1212
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1213 octave_value get_default (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1214
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1215 octave_value get_defaults (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1216 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1217 return default_properties.as_struct ("default");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1218 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1219
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1220 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1221
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1222 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1223
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1224 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1225
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1226 void reparent (const graphics_handle& np) { xproperties.reparent (np); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1227
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1228 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1229
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1230 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1231
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1232 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1233 property_list default_properties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1234 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1235
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1236 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1237
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1238 class line : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1239 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1240 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1241 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1242 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1243 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1244 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1245
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1246 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1247
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1248 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1249
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1250 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1251
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1252 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1253
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1254 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1255
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1256 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1257
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1258 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1259 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1260
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1261 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1262 octave_value xdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1263 octave_value ydata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1264 octave_value zdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1265 octave_value ldata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1266 octave_value udata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1267 octave_value xldata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1268 octave_value xudata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1269 color_property color
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1270 octave_value linestyle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1271 octave_value linewidth
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1272 octave_value marker
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1273 octave_value markeredgecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1274 octave_value markerfacecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1275 octave_value markersize
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1276 octave_value keylabel
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1277 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1278
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1279 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1280 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1281
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1282 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1283 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1284
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1285 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1286 line (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1287 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1288 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1289 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1290 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1291
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1292 ~line (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1293
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1294 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1295
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1296 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1297
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1298 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1299 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1300 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1301 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1302 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1303 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1304
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1305 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1306 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1307 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1308 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1309
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1310 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1311 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1312 xproperties.set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1313 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1314
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1315 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1316 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1317 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1318 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1319
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1320 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1321 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1322 return xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1323 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1324
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1325 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1326
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1327 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1328
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1329 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1330
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1331 void reparent (const graphics_handle& h) { xproperties.reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1332
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1333 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1334
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1335 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1336 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1337
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1338 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1339
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1340 class text : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1341 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1342 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1343 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1344 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1345 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1346 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1347
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1348 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1349
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1350 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1351
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1352 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1353
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1354 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1355
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1356 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1357
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1358 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1359
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1360 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1361 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1362
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1363 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1364 octave_value string
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1365 octave_value units
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1366 octave_value position
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1367 octave_value rotation
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1368 octave_value horizontalalignment
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1369 octave_value color
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1370 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1371
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1372 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1373 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1374
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1375 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1376 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1377
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1378 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1379 text (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1380 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1381 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1382 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1383 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1384
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1385 ~text (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1386
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1387 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1388
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1389 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1390
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1391 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1392 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1393 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1394 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1395 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1396 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1397
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1398 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1399 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1400 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1401 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1402
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1403 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1404 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1405 xproperties.set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1406 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1407
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1408 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1409 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1410 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1411 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1412
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1413 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1414 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1415 return xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1416 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1417
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1418 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1419
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1420 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1421
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1422 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1423
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1424 void reparent (const graphics_handle& h) { xproperties.reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1425
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1426 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1427
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1428 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1429 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1430
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1431 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1432
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1433 class image : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1434 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1435 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1436 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1437 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1438 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1439 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1440
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1441 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1442
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1443 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1444
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1445 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1446
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1447 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1448
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1449 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1450
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1451 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1452
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1453 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1454 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1455
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1456 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1457 octave_value cdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1458 octave_value xdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1459 octave_value ydata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1460 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1461
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1462 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1463 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1464
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1465 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1466 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1467
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1468 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1469 image (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1470 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1471 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1472 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1473 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1474
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1475 ~image (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1476
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1477 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1478
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1479 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1480
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1481 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1482 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1483 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1484 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1485 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1486 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1487
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1488 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1489 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1490 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1491 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1492
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1493 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1494 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1495 xproperties.set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1496 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1497
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1498 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1499 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1500 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1501 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1502
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1503 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1504 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1505 return xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1506 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1507
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1508 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1509
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1510 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1511
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1512 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1513
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1514 void reparent (const graphics_handle& h) { xproperties.reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1515
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1516 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1517
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1518 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1519 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1520
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1521 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1522
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1523 class patch : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1524 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1525 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1526 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1527 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1528 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1529 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1530
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1531 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1532
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1533 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1534
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1535 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1536
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1537 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1538
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1539 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1540
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1541 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1542
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1543 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1544 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1545
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1546 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1547 octave_value cdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1548 octave_value xdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1549 octave_value ydata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1550 octave_value zdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1551 color_property facecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1552 octave_value facealpha
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1553 color_property edgecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1554 octave_value linestyle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1555 octave_value linewidth
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1556 octave_value marker
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1557 octave_value markeredgecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1558 octave_value markerfacecolor
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1559 octave_value markersize
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1560 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1561
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1562 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1563 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1564
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1565 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1566 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1567
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1568 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1569 patch (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1570 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1571 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1572 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1573 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1574
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1575 ~patch (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1576
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1577 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1578
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1579 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1580
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1581 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1582 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1583 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1584 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1585 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1586 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1587
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1588 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1589 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1590 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1591 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1592
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1593 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1594 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1595 xproperties.set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1596 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1597
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1598 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1599 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1600 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1601 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1602
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1603 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1604 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1605 return xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1606 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1607
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1608 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1609
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1610 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1611
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1612 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1613
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1614 void reparent (const graphics_handle& h) { xproperties.reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1615
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1616 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1617
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1618 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1619 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1620
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1621 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1622
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1623 class surface : public base_graphics_object
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1624 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1625 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1626 class properties : public base_properties
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1627 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1628 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1629 properties (const graphics_handle& mh, const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1630
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1631 ~properties (void) { }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1632
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1633 void set (const property_name& name, const octave_value& val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1634
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1635 octave_value get (void) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1636
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1637 octave_value get (const property_name& name) const;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1638
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1639 std::string graphics_object_name (void) const { return go_name; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1640
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1641 static property_list::pval_map_type factory_defaults (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1642
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1643 // See the genprops.awk script for an explanation of the
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1644 // properties declarations.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1645
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1646 BEGIN_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1647 octave_value xdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1648 octave_value ydata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1649 octave_value zdata
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1650 octave_value keylabel
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1651 END_PROPERTIES
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1652
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1653 static std::string go_name;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1654 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1655
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1656 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1657 properties xproperties;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1658
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1659 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1660 surface (const graphics_handle& mh, const graphics_handle& p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1661 : base_graphics_object (), xproperties (mh, p)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1662 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1663 xproperties.override_defaults (*this);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1664 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1665
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1666 ~surface (void) { xproperties.delete_children (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1667
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1668 std::string type (void) const { return xproperties.graphics_object_name (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1669
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1670 void mark_modified (void) { xproperties.mark_modified (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1671
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1672 void override_defaults (base_graphics_object& obj)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1673 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1674 // Allow parent (figure) to override first (properties knows how
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1675 // to find the parent object).
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1676 xproperties.override_defaults (obj);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1677 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1678
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1679 void set_from_list (property_list& plist)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1680 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1681 xproperties.set_from_list (*this, plist);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1682 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1683
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1684 void set (const property_name& name, const octave_value& val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1685 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1686 xproperties.set (name, val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1687 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1688
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1689 octave_value get (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1690 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1691 return xproperties.get ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1692 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1693
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1694 octave_value get (const property_name& name) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1695 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1696 return xproperties.get (name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1697 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1698
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1699 graphics_handle get_parent (void) const { return xproperties.get_parent (); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1700
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1701 void remove_child (const graphics_handle& h) { xproperties.remove_child (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1702
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1703 void adopt (const graphics_handle& h) { xproperties.adopt (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1704
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1705 void reparent (const graphics_handle& h) { xproperties.reparent (h); }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1706
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1707 base_properties& get_properties (void) { return xproperties; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1708
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1709 bool valid_object (void) const { return true; }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1710 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1711
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1712 octave_value
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1713 get_property_from_handle (double handle, const std::string &property,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1714 const std::string &func);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1715 bool
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1716 set_property_in_handle (double handle, const std::string &property,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1717 const octave_value &arg, const std::string &func);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1718
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1719 // ---------------------------------------------------------------------
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1720
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1721 class gh_manager
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1722 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1723 protected:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1724
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1725 gh_manager (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1726
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1727 public:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1728
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1729 static bool instance_ok (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1730 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1731 bool retval = true;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1732
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1733 if (! instance)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1734 instance = new gh_manager ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1735
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1736 if (! instance)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1737 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1738 ::error ("unable to create gh_manager!");
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1739
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1740 retval = false;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1741 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1742
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1743 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1744 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1745
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1746 static void free (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1747 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1748 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1749 instance->do_free (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1750 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1751
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1752 static graphics_handle lookup (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1753 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1754 return instance_ok () ? instance->do_lookup (val) : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1755 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1756
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1757 static graphics_object get_object (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1758 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1759 return instance_ok () ? instance->do_get_object (h) : graphics_object ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1760 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1761
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1762 static graphics_handle
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1763 make_graphics_handle (const std::string& go_name,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1764 const graphics_handle& parent)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1765 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1766 return instance_ok ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1767 ? instance->do_make_graphics_handle (go_name, parent)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1768 : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1769 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1770
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1771 static graphics_handle make_figure_handle (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1772 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1773 return instance_ok ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1774 ? instance->do_make_figure_handle (val) : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1775 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1776
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1777 static void push_figure (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1778 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1779 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1780 instance->do_push_figure (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1781 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1782
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1783 static void pop_figure (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1784 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1785 if (instance_ok ())
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1786 instance->do_pop_figure (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1787 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1788
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1789 static graphics_handle current_figure (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1790 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1791 return instance_ok ()
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1792 ? instance->do_current_figure () : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1793 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1794
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1795 static Matrix handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1796 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1797 return instance_ok () ? instance->do_handle_list () : Matrix ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1798 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1799
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1800 static Matrix figure_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1801 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1802 return instance_ok () ? instance->do_figure_handle_list () : Matrix ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1803 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1804
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1805 private:
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1806
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1807 static gh_manager *instance;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1808
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1809 typedef std::map<graphics_handle, graphics_object>::iterator iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1810 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1811
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1812 typedef std::set<graphics_handle>::iterator free_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1813 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1814
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1815 typedef std::list<graphics_handle>::iterator figure_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1816 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1817
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1818 // A map of handles to graphics objects.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1819 std::map<graphics_handle, graphics_object> handle_map;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1820
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1821 // The available graphics handles.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1822 std::set<graphics_handle> handle_free_list;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1823
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1824 // The next handle available if handle_free_list is empty.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1825 graphics_handle next_handle;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1826
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1827 // The allocated figure handles. Top of the stack is most recently
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1828 // created.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1829 std::list<graphics_handle> figure_list;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1830
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1831 graphics_handle get_handle (const std::string& go_name);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1832
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1833 void do_free (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1834
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1835 graphics_handle do_lookup (double val)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1836 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1837 iterator p = handle_map.find (val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1838
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1839 return (p != handle_map.end ()) ? p->first : graphics_handle ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1840 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1841
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1842 graphics_object do_get_object (const graphics_handle& h)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1843 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1844 iterator p = handle_map.find (h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1845
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1846 return (p != handle_map.end ()) ? p->second : graphics_object ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1847 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1848
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1849 graphics_handle do_make_graphics_handle (const std::string& go_name,
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1850 const graphics_handle& p);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1851
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1852 graphics_handle do_make_figure_handle (double val);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1853
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1854 Matrix do_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1855 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1856 Matrix retval (1, handle_map.size ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1857 octave_idx_type i = 0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1858 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1859 retval(i++) = p->first;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1860 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1861 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1862
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1863 Matrix do_figure_handle_list (void)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1864 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1865 Matrix retval (1, figure_list.size ());
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1866 octave_idx_type i = 0;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1867 for (const_figure_list_iterator p = figure_list.begin ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1868 p != figure_list.end ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1869 p++)
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1870 retval(i++) = *p;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1871 return retval;
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1872 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1873
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1874 void do_push_figure (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1875
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1876 void do_pop_figure (const graphics_handle& h);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1877
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1878 graphics_handle do_current_figure (void) const
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1879 {
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1880 return figure_list.empty () ? graphics_handle () : figure_list.front ();
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1881 }
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1882 };
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1883
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1884
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1885 // This function is NOT equivalent to the scripting language function gcf.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1886 graphics_handle gcf (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1887
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1888 // This function is NOT equivalent to the scripting language function gca.
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1889 graphics_handle gca (void);
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1890
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1891 #endif
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1892
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1893 /*
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1894 ;;; Local Variables: ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1895 ;;; mode: C++ ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1896 ;;; End: ***
94bda6abc224 [project @ 2007-09-06 21:34:24 by jwe]
jwe
parents:
diff changeset
1897 */