Mercurial > hg > octave-jordi
annotate src/graphics.h.in @ 7864:56f781f38f0b
Add dynamic property creation
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Thu, 24 Apr 2008 16:43:31 +0200 |
parents | 8f3459a90bf3 |
children | b74039822fd2 |
rev | line source |
---|---|
6874 | 1 /* |
2 | |
3 Copyright (C) 2007 John W. Eaton | |
4 | |
5 This file is part of Octave. | |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
6874 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
6874 | 20 |
21 */ | |
22 | |
23 #if !defined (graphics_h) | |
24 #define graphics_h 1 | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include <config.h> | |
28 #endif | |
29 | |
30 #include <cctype> | |
31 | |
32 #include <algorithm> | |
33 #include <list> | |
34 #include <map> | |
35 #include <set> | |
36 #include <string> | |
37 | |
6890 | 38 #include "gripes.h" |
6874 | 39 #include "oct-map.h" |
40 #include "ov.h" | |
41 | |
7189 | 42 class caseless_str : public std::string |
43 { | |
44 public: | |
45 typedef std::string::iterator iterator; | |
46 typedef std::string::const_iterator const_iterator; | |
47 | |
48 caseless_str (void) : std::string () { } | |
49 caseless_str (const std::string& s) : std::string (s) { } | |
50 caseless_str (const char *s) : std::string (s) { } | |
51 | |
52 caseless_str (const caseless_str& name) : std::string (name) { } | |
53 | |
54 caseless_str& operator = (const caseless_str& pname) | |
55 { | |
56 std::string::operator = (pname); | |
57 return *this; | |
58 } | |
59 | |
60 operator std::string (void) const { return *this; } | |
61 | |
62 // Case-insensitive comparison. | |
63 bool compare (const std::string& s, size_t limit = NPOS) const | |
64 { | |
65 const_iterator p1 = begin (); | |
66 const_iterator p2 = s.begin (); | |
67 | |
68 size_t k = 0; | |
69 | |
70 while (p1 != end () && p2 != s.end () && k++ < limit) | |
71 { | |
72 if (std::tolower (*p1) != std::tolower (*p2)) | |
73 return false; | |
74 | |
75 *p1++; | |
76 *p2++; | |
77 } | |
78 | |
79 return (limit == NPOS) ? size () == s.size () : k == limit; | |
80 } | |
81 }; | |
82 | |
83 // --------------------------------------------------------------------- | |
84 | |
6874 | 85 class graphics_handle |
86 { | |
87 public: | |
88 graphics_handle (void) : val (octave_NaN) { } | |
89 | |
90 graphics_handle (const octave_value& a); | |
91 | |
92 graphics_handle (int a) : val (a) { } | |
93 | |
94 graphics_handle (double a) : val (a) { } | |
95 | |
96 graphics_handle (const graphics_handle& a) : val (a.val) { } | |
97 | |
98 graphics_handle& operator = (const graphics_handle& a) | |
99 { | |
100 if (&a != this) | |
101 val = a.val; | |
102 | |
103 return *this; | |
104 } | |
105 | |
106 ~graphics_handle (void) { } | |
107 | |
108 double value (void) const { return val; } | |
109 | |
110 octave_value as_octave_value (void) const | |
111 { | |
112 return ok () ? octave_value (val) : octave_value (Matrix ()); | |
113 } | |
114 | |
115 graphics_handle operator ++ (void) | |
116 { | |
117 ++val; | |
118 return *this; | |
119 } | |
120 | |
121 graphics_handle operator ++ (int) | |
122 { | |
123 graphics_handle h = *this; | |
124 ++val; | |
125 return h; | |
126 } | |
127 | |
128 graphics_handle operator -- (void) | |
129 { | |
130 --val; | |
131 return *this; | |
132 } | |
133 | |
134 graphics_handle operator -- (int) | |
135 { | |
136 graphics_handle h = *this; | |
137 --val; | |
138 return h; | |
139 } | |
140 | |
141 bool ok (void) const { return ! xisnan (val); } | |
142 | |
143 private: | |
144 double val; | |
145 }; | |
146 | |
147 inline bool | |
148 operator == (const graphics_handle& a, const graphics_handle& b) | |
149 { | |
150 return a.value () == b.value (); | |
151 } | |
152 | |
153 inline bool | |
154 operator != (const graphics_handle& a, const graphics_handle& b) | |
155 { | |
156 return a.value () != b.value (); | |
157 } | |
158 | |
159 inline bool | |
160 operator < (const graphics_handle& a, const graphics_handle& b) | |
161 { | |
162 return a.value () < b.value (); | |
163 } | |
164 | |
165 inline bool | |
166 operator <= (const graphics_handle& a, const graphics_handle& b) | |
167 { | |
168 return a.value () <= b.value (); | |
169 } | |
170 | |
171 inline bool | |
172 operator >= (const graphics_handle& a, const graphics_handle& b) | |
173 { | |
174 return a.value () >= b.value (); | |
175 } | |
176 | |
177 inline bool | |
178 operator > (const graphics_handle& a, const graphics_handle& b) | |
179 { | |
180 return a.value () > b.value (); | |
181 } | |
182 | |
183 // --------------------------------------------------------------------- | |
184 | |
7427 | 185 class base_scaler |
186 { | |
187 public: | |
188 base_scaler (void) { } | |
189 | |
7441 | 190 virtual ~base_scaler (void) { } |
7440 | 191 |
7427 | 192 virtual Matrix scale (const Matrix& m) const |
193 { | |
194 error ("invalid axis scale"); | |
195 return m; | |
196 } | |
197 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
198 virtual NDArray scale (const NDArray& m) const |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
199 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
200 error ("invalid axis scale"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
201 return m; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
202 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
203 |
7427 | 204 virtual double scale (double d) const |
205 { | |
206 error ("invalid axis scale"); | |
207 return d; | |
208 } | |
209 | |
210 virtual double unscale (double d) const | |
211 { | |
212 error ("invalid axis scale"); | |
213 return d; | |
214 } | |
215 | |
216 virtual base_scaler* clone () const | |
217 { return new base_scaler (); } | |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
218 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
219 virtual bool is_linear (void) const |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
220 { return false; } |
7427 | 221 }; |
222 | |
223 class lin_scaler : public base_scaler | |
224 { | |
225 public: | |
226 lin_scaler (void) { } | |
227 | |
228 Matrix scale (const Matrix& m) const { return m; } | |
229 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
230 NDArray scale (const NDArray& m) const { return m; } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
231 |
7427 | 232 double scale (double d) const { return d; } |
233 | |
234 double unscale (double d) const { return d; } | |
235 | |
236 base_scaler* clone (void) const { return new lin_scaler (); } | |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
237 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
238 bool is_linear (void) const { return true; } |
7427 | 239 }; |
240 | |
241 class log_scaler : public base_scaler | |
242 { | |
243 public: | |
244 log_scaler (void) { } | |
245 | |
246 Matrix scale (const Matrix& m) const | |
247 { | |
248 Matrix retval (m.rows (), m.cols ()); | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
249 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
250 do_scale (m.data (), retval.fortran_vec (), m.numel ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
251 return retval; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
252 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
253 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
254 NDArray scale (const NDArray& m) const |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
255 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
256 NDArray retval (m.dims ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
257 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
258 do_scale (m.data (), retval.fortran_vec (), m.numel ()); |
7427 | 259 return retval; |
260 } | |
261 | |
262 double scale (double d) const | |
263 { return log10 (d); } | |
264 | |
265 double unscale (double d) const | |
266 { return pow (10.0, d); } | |
267 | |
268 base_scaler* clone (void) const | |
269 { return new log_scaler (); } | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
270 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
271 private: |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
272 void do_scale (const double *src, double *dest, int n) const |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
273 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
274 for (int i = 0; i < n; i++) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
275 dest[i] = log10(src[i]); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
276 } |
7427 | 277 }; |
278 | |
279 class scaler | |
280 { | |
281 public: | |
282 scaler (void) : rep (new base_scaler ()) { } | |
283 | |
284 scaler (const scaler& s) : rep (s.rep->clone()) { } | |
285 | |
286 ~scaler (void) { delete rep; } | |
287 | |
288 Matrix scale (const Matrix& m) const | |
289 { return rep->scale (m); } | |
290 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
291 NDArray scale (const NDArray& m) const |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
292 { return rep->scale (m); } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
293 |
7427 | 294 double scale (double d) const |
295 { return rep->scale (d); } | |
296 | |
297 double unscale (double d) const | |
298 { return rep->unscale (d); } | |
299 | |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
300 bool is_linear (void) const |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
301 { return rep->is_linear (); } |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
302 |
7427 | 303 scaler& operator = (const scaler& s) |
304 { | |
305 if (rep) | |
306 { | |
307 delete rep; | |
308 rep = 0; | |
309 } | |
310 | |
311 rep = s.rep->clone (); | |
312 | |
313 return *this; | |
314 } | |
315 | |
316 scaler& operator = (const std::string& s) | |
317 { | |
318 if (rep) | |
319 { | |
320 delete rep; | |
321 rep = 0; | |
322 } | |
323 | |
324 if (s == "log") | |
325 rep = new log_scaler (); | |
326 else if (s == "linear") | |
327 rep = new lin_scaler (); | |
328 else | |
329 rep = new base_scaler (); | |
330 | |
331 return *this; | |
332 } | |
333 | |
334 private: | |
335 base_scaler *rep; | |
336 }; | |
337 | |
338 // --------------------------------------------------------------------- | |
339 | |
7363 | 340 class property; |
341 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
342 enum listener_mode { POSTSET }; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
343 |
7363 | 344 class base_property |
345 { | |
346 public: | |
347 friend class property; | |
348 | |
349 public: | |
7850
56254a8d4d59
Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
350 base_property (void) : count (1) { } |
7363 | 351 |
352 base_property (const std::string& s, const graphics_handle& h) | |
7850
56254a8d4d59
Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
353 : count (1), name (s), parent (h), hidden (false) { } |
7363 | 354 |
355 base_property (const base_property& p) | |
7850
56254a8d4d59
Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
356 : count (1), name (p.name), parent (p.parent), hidden (p.hidden) { } |
7363 | 357 |
358 virtual ~base_property (void) { } | |
359 | |
360 bool ok (void) const { return parent.ok (); } | |
361 | |
362 std::string get_name (void) const { return name; } | |
363 | |
364 void set_name (const std::string& s) { name = s; } | |
365 | |
366 graphics_handle get_parent (void) const { return parent; } | |
367 | |
368 void set_parent (const graphics_handle &h) { parent = h; } | |
369 | |
370 bool is_hidden (void) const { return hidden; } | |
371 | |
372 void set_hidden (bool flag) { hidden = flag; } | |
373 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
374 void set (const octave_value& v, bool do_run = true) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
375 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
376 do_set (v); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
377 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
378 if (do_run && ! error_state) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
379 run_listeners (POSTSET); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
380 } |
7363 | 381 |
382 virtual octave_value get (void) const | |
383 { | |
384 error ("get: invalid property \"%s\"", name.c_str ()); | |
385 return octave_value (); | |
386 } | |
387 | |
388 base_property& operator = (const octave_value& val) | |
389 { | |
390 set (val); | |
391 return *this; | |
392 } | |
393 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
394 void add_listener (const octave_value& v, listener_mode mode = POSTSET) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
395 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
396 octave_value_list& l = listeners[mode]; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
397 l.resize (l.length () + 1, v); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
398 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
399 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
400 OCTINTERP_API void run_listeners (listener_mode mode = POSTSET); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
401 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
402 virtual base_property* clone (void) const |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
403 { return new base_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
404 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
405 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
406 virtual void do_set (const octave_value&) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
407 { error ("set: invalid property \"%s\"", name.c_str ()); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
408 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
409 private: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
410 typedef std::map<listener_mode, octave_value_list> listener_map; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
411 typedef std::map<listener_mode, octave_value_list>::iterator listener_map_iterator; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
412 typedef std::map<listener_mode, octave_value_list>::const_iterator listener_map_const_iterator; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
413 |
7363 | 414 private: |
415 int count; | |
416 std::string name; | |
417 graphics_handle parent; | |
418 bool hidden; | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
419 listener_map listeners; |
7363 | 420 }; |
421 | |
422 // --------------------------------------------------------------------- | |
423 | |
424 class string_property : public base_property | |
425 { | |
426 public: | |
427 string_property (const std::string& s, const graphics_handle& h, | |
428 const std::string& val = "") | |
429 : base_property (s, h), str (val) { } | |
430 | |
431 string_property (const string_property& p) | |
432 : base_property (p), str (p.str) { } | |
433 | |
434 octave_value get (void) const | |
435 { return octave_value (str); } | |
436 | |
437 std::string string_value (void) const { return str; } | |
438 | |
439 string_property& operator = (const octave_value& val) | |
440 { | |
441 set (val); | |
442 return *this; | |
443 } | |
444 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
445 base_property* clone (void) const { return new string_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
446 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
447 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
448 void do_set (const octave_value& val) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
449 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
450 if (val.is_string ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
451 str = val.string_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
452 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
453 error ("set: invalid string property value for \"%s\"", |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
454 get_name ().c_str ()); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
455 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
456 |
7363 | 457 private: |
458 std::string str; | |
459 }; | |
460 | |
461 // --------------------------------------------------------------------- | |
462 | |
463 class radio_values | |
464 { | |
465 public: | |
466 OCTINTERP_API radio_values (const std::string& opt_string = std::string ()); | |
467 | |
468 radio_values (const radio_values& a) | |
469 : default_val (a.default_val), possible_vals (a.possible_vals) { } | |
470 | |
471 radio_values& operator = (const radio_values& a) | |
472 { | |
473 if (&a != this) | |
474 { | |
475 default_val = a.default_val; | |
476 possible_vals = a.possible_vals; | |
477 } | |
478 | |
479 return *this; | |
480 } | |
481 | |
482 std::string default_value (void) const { return default_val; } | |
483 | |
484 bool validate (const std::string& val) | |
485 { | |
486 bool retval = true; | |
487 | |
488 if (! contains (val)) | |
489 { | |
490 error ("invalid value = %s", val.c_str ()); | |
491 retval = false; | |
492 } | |
493 | |
494 return retval; | |
495 } | |
496 | |
497 bool contains (const std::string& val) | |
498 { | |
499 return (possible_vals.find (val) != possible_vals.end ()); | |
500 } | |
501 | |
502 private: | |
503 // Might also want to cache | |
504 std::string default_val; | |
505 std::set<caseless_str> possible_vals; | |
506 }; | |
507 | |
508 class radio_property : public base_property | |
509 { | |
510 public: | |
7364 | 511 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 512 const radio_values& v = radio_values ()) |
7364 | 513 : base_property (nm, h), |
7363 | 514 vals (v), current_val (v.default_value ()) { } |
515 | |
7364 | 516 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 517 const std::string& v) |
7364 | 518 : base_property (nm, h), |
7363 | 519 vals (v), current_val (vals.default_value ()) { } |
520 | |
7364 | 521 radio_property (const std::string& nm, const graphics_handle& h, |
7363 | 522 const radio_values& v, const std::string& def) |
7364 | 523 : base_property (nm, h), |
7363 | 524 vals (v), current_val (def) { } |
525 | |
526 radio_property (const radio_property& p) | |
527 : base_property (p), vals (p.vals), current_val (p.current_val) { } | |
528 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
529 octave_value get (void) const { return octave_value (current_val); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
530 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
531 const std::string& current_value (void) const { return current_val; } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
532 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
533 bool is (const caseless_str& v) const |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
534 { return v.compare (current_val); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
535 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
536 radio_property& operator = (const octave_value& val) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
537 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
538 set (val); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
539 return *this; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
540 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
541 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
542 base_property* clone (void) const { return new radio_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
543 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
544 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
545 void do_set (const octave_value& newval) |
7363 | 546 { |
547 if (newval.is_string ()) | |
548 { | |
549 std::string s = newval.string_value (); | |
550 if (vals.validate (s)) | |
551 current_val = s; | |
552 else | |
553 error ("set: invalid value for radio property \"%s\" (value = %s)", | |
554 get_name ().c_str (), s.c_str ()); | |
555 } | |
556 else | |
557 error ("set: invalid value for radio property \"%s\"", | |
558 get_name ().c_str ()); | |
559 } | |
560 | |
561 private: | |
562 radio_values vals; | |
563 std::string current_val; | |
564 }; | |
565 | |
566 // --------------------------------------------------------------------- | |
567 | |
568 class color_values | |
569 { | |
570 public: | |
571 color_values (double r = 0, double g = 0, double b = 1) | |
572 : xrgb (1, 3) | |
573 { | |
574 xrgb(0) = r; | |
575 xrgb(1) = g; | |
576 xrgb(2) = b; | |
577 | |
578 validate (); | |
579 } | |
580 | |
581 color_values (std::string str) | |
582 : xrgb (1, 3) | |
583 { | |
584 if (! str2rgb (str)) | |
585 error ("invalid color specification: %s", str.c_str ()); | |
586 } | |
587 | |
588 color_values (const color_values& c) | |
589 : xrgb (c.xrgb) | |
590 { } | |
591 | |
592 color_values& operator = (const color_values& c) | |
593 { | |
594 if (&c != this) | |
595 xrgb = c.xrgb; | |
596 | |
597 return *this; | |
598 } | |
599 | |
600 Matrix rgb (void) const { return xrgb; } | |
601 | |
602 operator octave_value (void) const { return xrgb; } | |
603 | |
604 void validate (void) const | |
605 { | |
606 for (int i = 0; i < 3; i++) | |
607 { | |
608 if (xrgb(i) < 0 || xrgb(i) > 1) | |
609 { | |
610 error ("invalid RGB color specification"); | |
611 break; | |
612 } | |
613 } | |
614 } | |
615 | |
616 private: | |
617 Matrix xrgb; | |
618 | |
619 OCTINTERP_API bool str2rgb (std::string str); | |
620 }; | |
621 | |
622 class color_property : public base_property | |
623 { | |
624 public: | |
625 color_property (const color_values& c, const radio_values& v) | |
626 : base_property ("", graphics_handle ()), | |
627 current_type (color_t), color_val (c), radio_val (v), | |
628 current_val (v.default_value ()) | |
629 { } | |
630 | |
7364 | 631 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 632 const color_values& c = color_values (), |
633 const radio_values& v = radio_values ()) | |
7364 | 634 : base_property (nm, h), |
7363 | 635 current_type (color_t), color_val (c), radio_val (v), |
636 current_val (v.default_value ()) | |
637 { } | |
638 | |
7364 | 639 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 640 const radio_values& v) |
7364 | 641 : base_property (nm, h), |
7363 | 642 current_type (radio_t), color_val (color_values ()), radio_val (v), |
643 current_val (v.default_value ()) | |
644 { } | |
645 | |
7364 | 646 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 647 const std::string& v) |
7364 | 648 : base_property (nm, h), |
7363 | 649 current_type (radio_t), color_val (color_values ()), radio_val (v), |
650 current_val (radio_val.default_value ()) | |
651 { } | |
652 | |
7364 | 653 color_property (const std::string& nm, const graphics_handle& h, |
7363 | 654 const color_property& v) |
7364 | 655 : base_property (nm, h), |
7363 | 656 current_type (v.current_type), color_val (v.color_val), |
657 radio_val (v.radio_val), current_val (v.current_val) | |
658 { } | |
659 | |
660 color_property (const color_property& p) | |
661 : base_property (p), current_type (p.current_type), | |
662 color_val (p.color_val), radio_val (p.radio_val), | |
663 current_val (p.current_val) { } | |
664 | |
665 octave_value get (void) const | |
666 { | |
667 if (current_type == color_t) | |
668 return color_val.rgb (); | |
669 | |
670 return current_val; | |
671 } | |
672 | |
673 bool is_rgb (void) const { return (current_type == color_t); } | |
674 | |
675 bool is_radio (void) const { return (current_type == radio_t); } | |
676 | |
677 bool is (const std::string& v) const | |
678 { return (is_radio () && current_val == v); } | |
679 | |
680 Matrix rgb (void) const | |
681 { | |
682 if (current_type != color_t) | |
683 error ("color has no rgb value"); | |
684 | |
685 return color_val.rgb (); | |
686 } | |
687 | |
688 const std::string& current_value (void) const | |
689 { | |
690 if (current_type != radio_t) | |
691 error ("color has no radio value"); | |
692 | |
693 return current_val; | |
694 } | |
695 | |
696 color_property& operator = (const octave_value& val) | |
697 { | |
698 set (val); | |
699 return *this; | |
700 } | |
701 | |
702 operator octave_value (void) const { return get (); } | |
703 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
704 base_property* clone (void) const { return new color_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
705 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
706 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
707 OCTINTERP_API void do_set (const octave_value& newval); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
708 |
7363 | 709 private: |
710 enum current_enum { color_t, radio_t } current_type; | |
711 color_values color_val; | |
712 radio_values radio_val; | |
713 std::string current_val; | |
714 }; | |
715 | |
716 // --------------------------------------------------------------------- | |
717 | |
718 class double_property : public base_property | |
719 { | |
720 public: | |
7364 | 721 double_property (const std::string& nm, const graphics_handle& h, |
7363 | 722 double d = 0) |
7364 | 723 : base_property (nm, h), |
7363 | 724 current_val (d) { } |
725 | |
726 double_property (const double_property& p) | |
727 : base_property (p), current_val (p.current_val) { } | |
728 | |
729 octave_value get (void) const { return octave_value (current_val); } | |
730 | |
731 double double_value (void) const { return current_val; } | |
732 | |
733 double_property& operator = (const octave_value& val) | |
734 { | |
735 set (val); | |
736 return *this; | |
737 } | |
738 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
739 base_property* clone (void) const { return new double_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
740 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
741 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
742 void do_set (const octave_value& v) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
743 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
744 if (v.is_scalar_type () && v.is_real_type ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
745 current_val = v.double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
746 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
747 error ("set: invalid value for double property \"%s\"", |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
748 get_name ().c_str ()); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
749 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
750 |
7363 | 751 private: |
752 double current_val; | |
753 }; | |
754 | |
755 // --------------------------------------------------------------------- | |
756 | |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
757 class double_radio_property : public base_property |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
758 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
759 public: |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
760 double_radio_property (double d, const radio_values& v) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
761 : base_property ("", graphics_handle ()), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
762 current_type (double_t), dval (d), radio_val (v), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
763 current_val (v.default_value ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
764 { } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
765 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
766 double_radio_property (const std::string& nm, const graphics_handle& h, |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
767 const std::string& v) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
768 : base_property (nm, h), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
769 current_type (radio_t), dval (0), radio_val (v), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
770 current_val (radio_val.default_value ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
771 { } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
772 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
773 double_radio_property (const std::string& nm, const graphics_handle& h, |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
774 const double_radio_property& v) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
775 : base_property (nm, h), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
776 current_type (v.current_type), dval (v.dval), |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
777 radio_val (v.radio_val), current_val (v.current_val) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
778 { } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
779 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
780 double_radio_property (const double_radio_property& p) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
781 : base_property (p), current_type (p.current_type), |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
782 dval (p.dval), radio_val (p.radio_val), |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
783 current_val (p.current_val) { } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
784 |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
785 octave_value get (void) const |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
786 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
787 if (current_type == double_t) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
788 return dval; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
789 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
790 return current_val; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
791 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
792 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
793 bool is_double (void) const { return (current_type == double_t); } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
794 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
795 bool is_radio (void) const { return (current_type == radio_t); } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
796 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
797 bool is (const std::string& v) const |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
798 { return (is_radio () && current_val == v); } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
799 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
800 double double_value (void) const |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
801 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
802 if (current_type != double_t) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
803 error ("%s: property has no double", get_name ().c_str ()); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
804 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
805 return dval; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
806 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
807 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
808 const std::string& current_value (void) const |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
809 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
810 if (current_type != radio_t) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
811 error ("%s: property has no radio value"); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
812 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
813 return current_val; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
814 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
815 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
816 double_radio_property& operator = (const octave_value& val) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
817 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
818 set (val); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
819 return *this; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
820 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
821 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
822 operator octave_value (void) const { return get (); } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
823 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
824 base_property* clone (void) const |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
825 { return new double_radio_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
826 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
827 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
828 OCTINTERP_API void do_set (const octave_value& v); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
829 |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
830 private: |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
831 enum current_enum { double_t, radio_t } current_type; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
832 double dval; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
833 radio_values radio_val; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
834 std::string current_val; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
835 }; |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
836 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
837 // --------------------------------------------------------------------- |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
838 |
7363 | 839 class array_property : public base_property |
840 { | |
841 public: | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
842 array_property (void) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
843 : base_property ("", graphics_handle ()), data (Matrix ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
844 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
845 get_data_limits (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
846 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
847 |
7364 | 848 array_property (const std::string& nm, const graphics_handle& h, |
7363 | 849 const octave_value& m) |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
850 : base_property (nm, h), data (m) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
851 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
852 get_data_limits (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
853 } |
7363 | 854 |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
855 // This copy constructor is only intended to be used |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
856 // internally to access min/max values; no need to |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
857 // copy constraints. |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
858 array_property (const array_property& p) |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
859 : base_property (p), data (p.data), |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
860 xmin (p.xmin), xmax (p.xmax), xminp (p.xminp) { } |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
861 |
7363 | 862 octave_value get (void) const { return data; } |
863 | |
864 void add_constraint (const std::string& type) | |
865 { type_constraints.push_back (type); } | |
866 | |
7524
a653856aa3e1
array_value::add_constraint: pass dim_vector as const reference, not value
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
867 void add_constraint (const dim_vector& dims) |
7363 | 868 { size_constraints.push_back (dims); } |
869 | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
870 double min_val (void) const { return xmin; } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
871 double max_val (void) const { return xmax; } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
872 double min_pos (void) const { return xminp; } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
873 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
874 Matrix get_limits (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
875 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
876 Matrix m (1, 3); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
877 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
878 m(0) = min_val (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
879 m(1) = max_val (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
880 m(2) = min_pos (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
881 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
882 return m; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
883 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
884 |
7363 | 885 array_property& operator = (const octave_value& val) |
886 { | |
887 set (val); | |
888 return *this; | |
889 } | |
890 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
891 base_property* clone (void) const |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
892 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
893 array_property *p = new array_property (*this); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
894 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
895 p->type_constraints = type_constraints; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
896 p->size_constraints = size_constraints; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
897 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
898 return p; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
899 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
900 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
901 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
902 void do_set (const octave_value& v) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
903 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
904 if (validate (v)) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
905 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
906 data = v; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
907 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
908 get_data_limits (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
909 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
910 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
911 error ("invalid value for array property \"%s\"", |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
912 get_name ().c_str ()); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
913 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
914 |
7363 | 915 private: |
916 OCTINTERP_API bool validate (const octave_value& v); | |
917 | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
918 OCTINTERP_API void get_data_limits (void); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
919 |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
920 protected: |
7363 | 921 octave_value data; |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
922 double xmin; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
923 double xmax; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
924 double xminp; |
7363 | 925 std::list<std::string> type_constraints; |
926 std::list<dim_vector> size_constraints; | |
927 }; | |
928 | |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
929 class row_vector_property : public array_property |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
930 { |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
931 public: |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
932 row_vector_property (const std::string& nm, const graphics_handle& h, |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
933 const octave_value& m) |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
934 : array_property (nm, h, m) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
935 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
936 add_constraint (dim_vector (-1, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
937 add_constraint (dim_vector (1, -1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
938 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
939 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
940 row_vector_property (const row_vector_property& p) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
941 : array_property (p) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
942 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
943 add_constraint (dim_vector (-1, 1)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
944 add_constraint (dim_vector (1, -1)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
945 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
946 |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
947 void add_constraint (const std::string& type) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
948 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
949 array_property::add_constraint (type); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
950 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
951 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
952 void add_constraint (const dim_vector& dims) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
953 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
954 array_property::add_constraint (dims); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
955 } |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
956 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
957 void add_constraint (octave_idx_type len) |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
958 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
959 size_constraints.remove (dim_vector (1, -1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
960 size_constraints.remove (dim_vector (-1, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
961 |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
962 add_constraint (dim_vector (1, len)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
963 add_constraint (dim_vector (len, 1)); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
964 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
965 |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
966 row_vector_property& operator = (const octave_value& val) |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
967 { |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
968 set (val); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
969 return *this; |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
970 } |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
971 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
972 base_property* clone (void) const |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
973 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
974 row_vector_property *p = new row_vector_property (*this); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
975 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
976 p->type_constraints = type_constraints; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
977 p->size_constraints = size_constraints; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
978 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
979 return p; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
980 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
981 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
982 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
983 void do_set (const octave_value& v) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
984 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
985 array_property::do_set (v); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
986 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
987 if (! error_state) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
988 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
989 dim_vector dv = data.dims (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
990 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
991 if (dv(0) > 1 && dv(1) == 1) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
992 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
993 int tmp = dv(0); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
994 dv(0) = dv(1); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
995 dv(1) = tmp; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
996 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
997 data = data.reshape (dv); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
998 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
999 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1000 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1001 |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
1002 private: |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
1003 OCTINTERP_API bool validate (const octave_value& v); |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
1004 }; |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
1005 |
7363 | 1006 // --------------------------------------------------------------------- |
1007 | |
1008 class bool_property : public radio_property | |
1009 { | |
1010 public: | |
7364 | 1011 bool_property (const std::string& nm, const graphics_handle& h, |
7363 | 1012 bool val) |
7364 | 1013 : radio_property (nm, h, radio_values (val ? "{on}|off" : "on|{off}")) |
7363 | 1014 { } |
1015 | |
7364 | 1016 bool_property (const std::string& nm, const graphics_handle& h, |
7363 | 1017 const char* val) |
7364 | 1018 : radio_property (nm, h, radio_values ("on|off"), val) |
7363 | 1019 { } |
1020 | |
1021 bool_property (const bool_property& p) | |
1022 : radio_property (p) { } | |
1023 | |
1024 bool is_on (void) const { return is ("on"); } | |
1025 | |
1026 bool_property& operator = (const octave_value& val) | |
1027 { | |
1028 set (val); | |
1029 return *this; | |
1030 } | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1031 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1032 base_property* clone (void) const { return new bool_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1033 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1034 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1035 void do_set (const octave_value& val) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1036 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1037 if (val.is_bool_scalar ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1038 radio_property::do_set (val.bool_value () ? "on" : "off"); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1039 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1040 radio_property::do_set (val); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1041 } |
7363 | 1042 }; |
1043 | |
1044 // --------------------------------------------------------------------- | |
1045 | |
1046 class handle_property : public base_property | |
1047 { | |
1048 public: | |
7364 | 1049 handle_property (const std::string& nm, const graphics_handle& h, |
7363 | 1050 const graphics_handle& val = graphics_handle ()) |
7364 | 1051 : base_property (nm, h), |
7363 | 1052 current_val (val) { } |
1053 | |
1054 handle_property (const handle_property& p) | |
1055 : base_property (p), current_val (p.current_val) { } | |
1056 | |
1057 octave_value get (void) const { return current_val.as_octave_value (); } | |
1058 | |
1059 graphics_handle handle_value (void) const { return current_val; } | |
1060 | |
1061 handle_property& operator = (const octave_value& val) | |
1062 { | |
1063 set (val); | |
1064 return *this; | |
1065 } | |
1066 | |
1067 handle_property& operator = (const graphics_handle& h) | |
1068 { | |
1069 set (octave_value (h.value ())); | |
1070 return *this; | |
1071 } | |
1072 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1073 base_property* clone (void) const { return new handle_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1074 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1075 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1076 OCTINTERP_API void do_set (const octave_value& v); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1077 |
7363 | 1078 private: |
1079 graphics_handle current_val; | |
1080 }; | |
1081 | |
1082 // --------------------------------------------------------------------- | |
1083 | |
1084 class any_property : public base_property | |
1085 { | |
1086 public: | |
7364 | 1087 any_property (const std::string& nm, const graphics_handle& h, |
7363 | 1088 const octave_value& m = Matrix ()) |
7364 | 1089 : base_property (nm, h), data (m) { } |
7363 | 1090 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1091 any_property (const any_property& p) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1092 : base_property (p), data (p.data) { } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1093 |
7363 | 1094 octave_value get (void) const { return data; } |
1095 | |
1096 any_property& operator = (const octave_value& val) | |
1097 { | |
1098 set (val); | |
1099 return *this; | |
1100 } | |
1101 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1102 base_property* clone (void) const { return new any_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1103 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1104 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1105 void do_set (const octave_value& v) { data = v; } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1106 |
7363 | 1107 private: |
1108 octave_value data; | |
1109 }; | |
1110 | |
1111 // --------------------------------------------------------------------- | |
1112 | |
1113 class callback_property : public base_property | |
1114 { | |
1115 public: | |
7364 | 1116 callback_property (const std::string& nm, const graphics_handle& h, |
7363 | 1117 const octave_value& m) |
7364 | 1118 : base_property (nm, h), callback (m) { } |
7363 | 1119 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1120 callback_property (const callback_property& p) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1121 : base_property (p), callback (p.callback) { } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1122 |
7363 | 1123 octave_value get (void) const { return callback; } |
1124 | |
7367 | 1125 OCTINTERP_API void execute (const octave_value& data = octave_value ()) const; |
7363 | 1126 |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1127 OCTINTERP_API static |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1128 void execute (const octave_value& cb, const graphics_handle& h, |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1129 const octave_value& data = octave_value ()); |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1130 |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1131 |
7363 | 1132 callback_property& operator = (const octave_value& val) |
1133 { | |
1134 set (val); | |
1135 return *this; | |
1136 } | |
1137 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1138 base_property* clone (void) const { return new callback_property (*this); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1139 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1140 protected: |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1141 void do_set (const octave_value& v) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1142 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1143 if (validate (v)) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1144 callback = v; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1145 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1146 error ("invalid value for callback property \"%s\"", |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1147 get_name ().c_str ()); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1148 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1149 |
7363 | 1150 private: |
1151 OCTINTERP_API bool validate (const octave_value& v) const; | |
1152 | |
1153 private: | |
1154 octave_value callback; | |
1155 }; | |
1156 | |
1157 // --------------------------------------------------------------------- | |
1158 | |
1159 class property | |
1160 { | |
1161 public: | |
1162 property (void) : rep (new base_property ("", graphics_handle ())) | |
7850
56254a8d4d59
Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
1163 { } |
7363 | 1164 |
1165 property (base_property *bp, bool persist = false) : rep (bp) | |
7850
56254a8d4d59
Smarter reference counting in base_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
1166 { if (persist) rep->count++; } |
7363 | 1167 |
1168 property (const property& p) | |
1169 { | |
1170 rep = p.rep; | |
1171 rep->count++; | |
1172 } | |
1173 | |
1174 ~property (void) | |
1175 { | |
1176 if (--rep->count <= 0) | |
1177 delete rep; | |
1178 } | |
1179 | |
1180 bool ok (void) const | |
1181 { return rep->ok (); } | |
1182 | |
1183 std::string get_name (void) const | |
1184 { return rep->get_name (); } | |
1185 | |
1186 void set_name (const std::string& name) | |
1187 { rep->set_name (name); } | |
1188 | |
1189 graphics_handle get_parent (void) const | |
1190 { return rep->get_parent (); } | |
1191 | |
1192 void set_parent (const graphics_handle& h) | |
1193 { rep->set_parent (h); } | |
1194 | |
1195 bool is_hidden (void) const | |
1196 { return rep->is_hidden (); } | |
1197 | |
1198 void set_hidden (bool flag) | |
1199 { rep->set_hidden (flag); } | |
1200 | |
1201 octave_value get (void) const | |
1202 { return rep->get (); } | |
1203 | |
1204 void set (const octave_value& val) | |
1205 { rep->set (val); } | |
1206 | |
1207 property& operator = (const octave_value& val) | |
1208 { | |
1209 *rep = val; | |
1210 return *this; | |
1211 } | |
1212 | |
1213 property& operator = (const property& p) | |
1214 { | |
1215 if (rep && --rep->count <= 0) | |
1216 delete rep; | |
1217 | |
1218 rep = p.rep; | |
1219 rep->count++; | |
1220 | |
1221 return *this; | |
1222 } | |
1223 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1224 void add_listener (const octave_value& v, listener_mode mode = POSTSET) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1225 { rep->add_listener (v, mode); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1226 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1227 void run_listeners (listener_mode mode = POSTSET) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1228 { rep->run_listeners (mode); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1229 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1230 OCTINTERP_API static |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1231 property create (const std::string& name, const graphics_handle& parent, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1232 const caseless_str& type, |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1233 const octave_value_list& args); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1234 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1235 property clone (void) const |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1236 { return property (rep->clone ()); } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1237 |
7363 | 1238 /* |
1239 const string_property& as_string_property (void) const | |
1240 { return *(dynamic_cast<string_property*> (rep)); } | |
1241 | |
1242 const radio_property& as_radio_property (void) const | |
1243 { return *(dynamic_cast<radio_property*> (rep)); } | |
1244 | |
1245 const color_property& as_color_property (void) const | |
1246 { return *(dynamic_cast<color_property*> (rep)); } | |
1247 | |
1248 const double_property& as_double_property (void) const | |
1249 { return *(dynamic_cast<double_property*> (rep)); } | |
1250 | |
1251 const bool_property& as_bool_property (void) const | |
1252 { return *(dynamic_cast<bool_property*> (rep)); } | |
1253 | |
1254 const handle_property& as_handle_property (void) const | |
1255 { return *(dynamic_cast<handle_property*> (rep)); } | |
1256 */ | |
1257 | |
1258 private: | |
1259 base_property *rep; | |
1260 }; | |
1261 | |
1262 // --------------------------------------------------------------------- | |
1263 | |
1264 class property_list | |
1265 { | |
1266 public: | |
1267 typedef std::map<std::string, octave_value> pval_map_type; | |
1268 typedef std::map<std::string, pval_map_type> plist_map_type; | |
1269 | |
1270 typedef pval_map_type::iterator pval_map_iterator; | |
1271 typedef pval_map_type::const_iterator pval_map_const_iterator; | |
1272 | |
1273 typedef plist_map_type::iterator plist_map_iterator; | |
1274 typedef plist_map_type::const_iterator plist_map_const_iterator; | |
1275 | |
1276 property_list (const plist_map_type& m = plist_map_type ()) | |
1277 : plist_map (m) { } | |
1278 | |
1279 ~property_list (void) { } | |
1280 | |
1281 void set (const caseless_str& name, const octave_value& val); | |
1282 | |
1283 octave_value lookup (const caseless_str& name) const; | |
1284 | |
1285 plist_map_iterator begin (void) { return plist_map.begin (); } | |
1286 plist_map_const_iterator begin (void) const { return plist_map.begin (); } | |
1287 | |
1288 plist_map_iterator end (void) { return plist_map.end (); } | |
1289 plist_map_const_iterator end (void) const { return plist_map.end (); } | |
1290 | |
1291 plist_map_iterator find (const std::string& go_name) | |
1292 { | |
1293 return plist_map.find (go_name); | |
1294 } | |
1295 | |
1296 plist_map_const_iterator find (const std::string& go_name) const | |
1297 { | |
1298 return plist_map.find (go_name); | |
1299 } | |
1300 | |
1301 Octave_map as_struct (const std::string& prefix_arg) const; | |
1302 | |
1303 private: | |
1304 plist_map_type plist_map; | |
1305 }; | |
1306 | |
1307 // --------------------------------------------------------------------- | |
1308 | |
7419 | 1309 class graphics_backend; |
1310 | |
1311 class base_graphics_backend | |
1312 { | |
1313 public: | |
1314 friend class graphics_backend; | |
1315 | |
1316 public: | |
1317 base_graphics_backend (const std::string& nm) | |
1318 : name (nm), count (0) { } | |
1319 | |
1320 virtual ~base_graphics_backend (void) { } | |
1321 | |
1322 std::string get_name (void) const { return name; } | |
1323 | |
1324 virtual bool is_valid (void) const { return false; } | |
1325 | |
7834
caab78e7e377
added checks for fltk & freetype in configure script
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
1326 virtual void close_figure (const octave_value& pstream) const |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1327 { gripe_invalid ("close_figure"); } |
7419 | 1328 |
1329 virtual void redraw_figure (const graphics_handle&) const | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1330 { gripe_invalid ("redraw_figure"); } |
7419 | 1331 |
1332 virtual void print_figure (const graphics_handle&, const std::string&, | |
1333 const std::string&, bool, | |
1334 const std::string& = "") const | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1335 { gripe_invalid ("print_figure"); } |
7419 | 1336 |
1337 virtual Matrix get_canvas_size (const graphics_handle&) const | |
1338 { | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1339 gripe_invalid ("get_canvas_size"); |
7419 | 1340 return Matrix (1, 2, 0.0); |
1341 } | |
1342 | |
7427 | 1343 virtual double get_screen_resolution (void) const |
1344 { | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1345 gripe_invalid ("get_screen_resolution"); |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1346 return 72.0; |
7427 | 1347 } |
7445 | 1348 |
1349 virtual Matrix get_screen_size (void) const | |
1350 { | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1351 gripe_invalid ("get_screen_size"); |
7445 | 1352 return Matrix (1, 2, 0.0); |
1353 } | |
7427 | 1354 |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1355 virtual void set_figure_position (const graphics_handle&, const Matrix&) const |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1356 { gripe_invalid ("set_figure_position"); } |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1357 |
7419 | 1358 private: |
1359 std::string name; | |
1360 int count; | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1361 |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1362 private: |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1363 void gripe_invalid (const std::string& fname) const |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1364 { |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1365 if (! is_valid ()) |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1366 error ("%s: invalid graphics backend", fname.c_str ()); |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1367 } |
7419 | 1368 }; |
1369 | |
1370 class graphics_backend | |
1371 { | |
1372 public: | |
1373 graphics_backend (void) | |
1374 : rep (new base_graphics_backend ("unknown")) | |
1375 { | |
1376 rep->count++; | |
1377 } | |
1378 | |
1379 graphics_backend (base_graphics_backend* b) | |
1380 : rep (b) | |
1381 { | |
1382 rep->count++; | |
1383 } | |
1384 | |
1385 graphics_backend (const graphics_backend& b) | |
1386 : rep (b.rep) | |
1387 { | |
1388 rep->count++; | |
1389 } | |
1390 | |
1391 ~graphics_backend (void) | |
1392 { | |
1393 if (--rep->count == 0) | |
1394 delete rep; | |
1395 } | |
1396 | |
1397 graphics_backend& operator = (const graphics_backend& b) | |
1398 { | |
1399 if (rep != b.rep) | |
1400 { | |
1401 if (--rep->count == 0) | |
1402 delete rep; | |
1403 | |
1404 rep = b.rep; | |
1405 rep->count++; | |
1406 } | |
1407 | |
1408 return *this; | |
1409 } | |
1410 | |
1411 operator bool (void) const { return rep->is_valid (); } | |
1412 | |
1413 std::string get_name (void) const { return rep->get_name (); } | |
1414 | |
1415 void close_figure (const octave_value& pstream) const | |
1416 { rep->close_figure (pstream); } | |
1417 | |
1418 void redraw_figure (const graphics_handle& fh) const | |
1419 { rep->redraw_figure (fh); } | |
1420 | |
1421 void print_figure (const graphics_handle& fh, const std::string& term, | |
1422 const std::string& file, bool mono, | |
1423 const std::string& debug_file = "") const | |
1424 { rep->print_figure (fh, term, file, mono, debug_file); } | |
1425 | |
1426 Matrix get_canvas_size (const graphics_handle& fh) const | |
1427 { return rep->get_canvas_size (fh); } | |
1428 | |
7427 | 1429 double get_screen_resolution (void) const |
1430 { return rep->get_screen_resolution (); } | |
1431 | |
7445 | 1432 Matrix get_screen_size (void) const |
1433 { return rep->get_screen_size (); } | |
1434 | |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1435 void set_figure_position (const graphics_handle& h, const Matrix& pos) const |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1436 { rep->set_figure_position (h, pos); } |
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
1437 |
7419 | 1438 OCTINTERP_API static graphics_backend default_backend (void); |
1439 | |
1440 static void register_backend (const graphics_backend& b) | |
1441 { available_backends[b.get_name ()] = b; } | |
1442 | |
1443 static void unregister_backend (const std::string& name) | |
1444 { available_backends.erase (name); } | |
1445 | |
7439 | 1446 static graphics_backend find_backend (const std::string& name) |
1447 { | |
1448 const_available_backends_iterator p = available_backends.find (name); | |
1449 | |
1450 if (p != available_backends.end ()) | |
1451 return p->second; | |
1452 else | |
1453 return default_backend (); | |
1454 } | |
1455 | |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1456 static Cell available_backends_list (void) |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1457 { |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1458 Cell m (1 , available_backends.size ()); |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1459 const_available_backends_iterator p; |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1460 int i; |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1461 |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1462 for (i = 0,p = available_backends.begin (); p != available_backends.end (); p++,i++) |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1463 m(i) = p->first; |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1464 |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1465 return m; |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1466 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1467 |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7834
diff
changeset
|
1468 |
7419 | 1469 private: |
1470 base_graphics_backend *rep; | |
1471 | |
7445 | 1472 static OCTINTERP_API std::map<std::string, graphics_backend> available_backends; |
7439 | 1473 |
1474 typedef std::map<std::string, graphics_backend>::iterator available_backends_iterator; | |
1475 typedef std::map<std::string, graphics_backend>::const_iterator const_available_backends_iterator; | |
7419 | 1476 }; |
1477 | |
1478 // --------------------------------------------------------------------- | |
1479 | |
6874 | 1480 class base_graphics_object; |
1481 | |
7365 | 1482 class OCTINTERP_API base_properties |
6874 | 1483 { |
1484 public: | |
7176 | 1485 base_properties (const std::string& ty = "unknown", |
7363 | 1486 const graphics_handle& mh = graphics_handle (), |
1487 const graphics_handle& p = graphics_handle ()) | |
7404 | 1488 : beingdeleted ("beingdeleted", mh, false), |
7366 | 1489 busyaction ("parent", mh, "{queue}|cancel"), |
7367 | 1490 buttondownfcn ("buttondownfcn", mh, Matrix ()), |
7404 | 1491 children (), |
7366 | 1492 clipping ("clipping", mh, true), |
7406 | 1493 createfcn ("createfcn", mh, Matrix ()), |
7367 | 1494 deletefcn ("deletefcn", mh, Matrix ()), |
7366 | 1495 handlevisibility ("handlevisibility", mh, "{on}|callback|off"), |
1496 hittest ("hittest", mh, true), | |
1497 interruptible ("interruptible", mh, true), | |
7404 | 1498 parent ("parent", mh, p), |
7366 | 1499 selected ("selected", mh, false), |
1500 selectionhighlight ("selectionhighlight", mh, true), | |
7404 | 1501 tag ("tag", mh), |
1502 type ("type", mh, ty), | |
7367 | 1503 userdata ("userdata", mh, Matrix ()), |
7403 | 1504 visible ("visible", mh, true), |
7404 | 1505 __modified__ ("__modified__", mh, true), |
1506 __myhandle__ (mh), | |
1507 uicontextmenu ("uicontextmenu", mh, graphics_handle ()) | |
7363 | 1508 { } |
6874 | 1509 |
1510 virtual ~base_properties (void) { } | |
1511 | |
1512 virtual std::string graphics_object_name (void) const { return "unknonwn"; } | |
1513 | |
1514 void mark_modified (void); | |
1515 | |
1516 void override_defaults (base_graphics_object& obj); | |
1517 | |
1518 // Look through DEFAULTS for properties with given CLASS_NAME, and | |
1519 // apply them to the current object with set (virtual method). | |
1520 | |
1521 void set_from_list (base_graphics_object& obj, property_list& defaults); | |
1522 | |
7363 | 1523 void insert_property (const std::string& name, property p) |
1524 { | |
1525 p.set_name (name); | |
1526 p.set_parent (__myhandle__); | |
1527 all_props[name] = p; | |
1528 } | |
1529 | |
1530 virtual void set (const caseless_str&, const octave_value&); | |
1531 | |
1532 virtual octave_value get (const caseless_str&) const; | |
1533 | |
7379 | 1534 virtual octave_value get (bool all = false) const; |
7363 | 1535 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1536 virtual property get_property (const caseless_str&); |
7363 | 1537 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1538 bool has_property (const caseless_str&); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1539 |
7363 | 1540 std::string get_tag (void) const { return tag.string_value (); } |
1541 | |
1542 graphics_handle get_parent (void) const { return parent.handle_value (); } | |
1543 | |
1544 std::string get_type (void) const { return type.string_value (); } | |
1545 | |
1546 bool is_modified (void) const { return __modified__.is_on (); } | |
7251 | 1547 |
1548 graphics_handle get___myhandle__ (void) const { return __myhandle__; } | |
7366 | 1549 |
1550 std::string get_busyaction (void) const { return busyaction.current_value (); } | |
1551 | |
1552 octave_value get_buttondownfcn (void) const { return buttondownfcn.get (); } | |
1553 | |
7435 | 1554 bool is_clipping (void) const { return clipping.is_on (); } |
7366 | 1555 std::string get_clipping (void) const { return clipping.current_value (); } |
1556 | |
7367 | 1557 void execute_createfcn (const octave_value& data = octave_value ()) const |
1558 { createfcn.execute (data); } | |
1559 | |
7366 | 1560 octave_value get_createfcn (void) const { return createfcn.get (); } |
1561 | |
7367 | 1562 void execute_deletefcn (const octave_value& data = octave_value ()) const |
1563 { deletefcn.execute (data); } | |
1564 | |
7366 | 1565 octave_value get_deletefcn (void) const { return deletefcn.get (); } |
1566 | |
1567 std::string get_handlevisibility (void) const { return handlevisibility.current_value (); } | |
1568 | |
1569 std::string get_hittest (void) const { return hittest.current_value (); } | |
1570 | |
1571 std::string get_interruptible (void) const { return interruptible.current_value (); } | |
1572 | |
1573 std::string get_selected (void) const { return selected.current_value (); } | |
1574 | |
1575 std::string get_selectionhighlight (void) const { return selectionhighlight.current_value (); } | |
1576 | |
1577 octave_value get_uicontextmenu (void) const { return uicontextmenu.get (); } | |
1578 | |
1579 octave_value get_userdata (void) const { return userdata.get (); } | |
7408 | 1580 |
1581 bool is_visible (void) const { return visible.is_on (); } | |
7366 | 1582 std::string get_visible (void) const { return visible.current_value (); } |
1583 | |
7403 | 1584 bool is_beingdeleted (void) const { return beingdeleted.is_on (); } |
1585 std::string get_beingdeleted (void) const { return beingdeleted.current_value (); } | |
1586 | |
7386 | 1587 virtual void remove_child (const graphics_handle& h); |
1588 | |
1589 virtual void adopt (const graphics_handle& h) | |
6874 | 1590 { |
1591 octave_idx_type n = children.numel (); | |
1592 children.resize (1, n+1); | |
7056 | 1593 children(n) = h.value (); |
6874 | 1594 } |
1595 | |
7419 | 1596 virtual graphics_backend get_backend (void) const; |
1597 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7524
diff
changeset
|
1598 virtual Matrix get_boundingbox (bool /*internal*/ = false) const |
7447 | 1599 { return Matrix (1, 4, 0.0); } |
1600 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1601 virtual void update_boundingbox (void); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
1602 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1603 virtual void add_listener (const caseless_str&, const octave_value&, |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1604 listener_mode = POSTSET); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1605 |
7363 | 1606 void set_tag (const octave_value& val) { tag = val; } |
7176 | 1607 |
6874 | 1608 void set_parent (const octave_value& val); |
1609 | |
7408 | 1610 void set_modified (const octave_value& val) { __modified__ = val; } |
1611 | |
7366 | 1612 void set_busyaction (const octave_value& val) |
1613 { | |
1614 if (! error_state) | |
1615 { | |
1616 busyaction = val; | |
1617 mark_modified (); | |
1618 } | |
1619 } | |
1620 | |
1621 void set_buttondownfcn (const octave_value& val) | |
1622 { | |
1623 if (! error_state) | |
1624 { | |
1625 buttondownfcn = val; | |
1626 mark_modified (); | |
1627 } | |
1628 } | |
1629 | |
1630 void set_clipping (const octave_value& val) | |
1631 { | |
1632 if (! error_state) | |
1633 { | |
1634 clipping = val; | |
1635 mark_modified (); | |
1636 } | |
1637 } | |
1638 | |
1639 void set_createfcn (const octave_value& val) | |
1640 { | |
1641 if (! error_state) | |
1642 { | |
1643 createfcn = val; | |
1644 mark_modified (); | |
1645 } | |
1646 } | |
1647 | |
1648 void set_deletefcn (const octave_value& val) | |
1649 { | |
1650 if (! error_state) | |
1651 { | |
1652 deletefcn = val; | |
1653 mark_modified (); | |
1654 } | |
1655 } | |
1656 | |
1657 void set_handlevisibility (const octave_value& val) | |
1658 { | |
1659 if (! error_state) | |
1660 { | |
1661 handlevisibility = val; | |
1662 mark_modified (); | |
1663 } | |
1664 } | |
1665 | |
1666 void set_hittest (const octave_value& val) | |
1667 { | |
1668 if (! error_state) | |
1669 { | |
1670 hittest = val; | |
1671 mark_modified (); | |
1672 } | |
1673 } | |
1674 | |
1675 void set_interruptible (const octave_value& val) | |
1676 { | |
1677 if (! error_state) | |
1678 { | |
1679 interruptible = val; | |
1680 mark_modified (); | |
1681 } | |
1682 } | |
1683 | |
1684 void set_selected (const octave_value& val) | |
1685 { | |
1686 if (! error_state) | |
1687 { | |
1688 selected = val; | |
1689 mark_modified (); | |
1690 } | |
1691 } | |
1692 | |
1693 void set_selectionhighlight (const octave_value& val) | |
1694 { | |
1695 if (! error_state) | |
1696 { | |
1697 selectionhighlight = val; | |
1698 mark_modified (); | |
1699 } | |
1700 } | |
1701 | |
1702 void set_uicontextmenu (const octave_value& val) | |
1703 { | |
1704 if (! error_state) | |
1705 { | |
1706 uicontextmenu = val; | |
1707 mark_modified (); | |
1708 } | |
1709 } | |
1710 | |
1711 void set_userdata (const octave_value& val) | |
1712 { | |
1713 if (! error_state) | |
1714 { | |
1715 userdata = val; | |
1716 mark_modified (); | |
1717 } | |
1718 } | |
1719 | |
1720 virtual void set_visible (const octave_value& val) | |
1721 { | |
1722 if (! error_state) | |
1723 { | |
1724 visible = val; | |
1725 mark_modified (); | |
1726 } | |
1727 } | |
1728 | |
7403 | 1729 void set_beingdeleted (const octave_value& val) |
1730 { | |
1731 if (! error_state) | |
1732 { | |
1733 beingdeleted = val; | |
1734 mark_modified (); | |
1735 } | |
1736 } | |
1737 | |
7366 | 1738 |
1739 | |
6874 | 1740 void reparent (const graphics_handle& new_parent) { parent = new_parent; } |
1741 | |
7214 | 1742 // Update data limits for AXIS_TYPE (xdata, ydata, etc.) in the parent |
1743 // axes object. | |
1744 | |
7386 | 1745 virtual void update_axis_limits (const std::string& axis_type) const; |
7214 | 1746 |
6874 | 1747 virtual void delete_children (void); |
1748 | |
7222 | 1749 Matrix get_children (void) const { return children; } |
1750 | |
1751 // FIXME -- these functions should be generated automatically by the | |
1752 // genprops.awk script. | |
1753 // | |
1754 // EMIT_BASE_PROPERTIES_GET_FUNCTIONS | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1755 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1756 virtual octave_value get_xlim (void) const { return octave_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1757 virtual octave_value get_ylim (void) const { return octave_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1758 virtual octave_value get_zlim (void) const { return octave_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1759 virtual octave_value get_clim (void) const { return octave_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1760 virtual octave_value get_alim (void) const { return octave_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1761 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1762 virtual bool is_xliminclude (void) const { return false; } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1763 virtual bool is_yliminclude (void) const { return false; } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1764 virtual bool is_zliminclude (void) const { return false; } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1765 virtual bool is_climinclude (void) const { return false; } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1766 virtual bool is_aliminclude (void) const { return false; } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1767 |
6874 | 1768 protected: |
7403 | 1769 // properties common to all objects |
1770 bool_property beingdeleted; | |
1771 radio_property busyaction; | |
1772 callback_property buttondownfcn; | |
7363 | 1773 // FIXME: use a property class for children |
6874 | 1774 Matrix children; |
7366 | 1775 bool_property clipping; |
1776 callback_property createfcn; | |
1777 callback_property deletefcn; | |
1778 radio_property handlevisibility; | |
1779 bool_property hittest; | |
1780 bool_property interruptible; | |
7403 | 1781 handle_property parent; |
7366 | 1782 bool_property selected; |
1783 bool_property selectionhighlight; | |
7403 | 1784 string_property tag; |
1785 string_property type; | |
7366 | 1786 any_property userdata; |
1787 bool_property visible; | |
7403 | 1788 // additional (octave-specific) properties |
1789 bool_property __modified__; | |
1790 graphics_handle __myhandle__; | |
1791 // FIXME: should this really be here? | |
1792 handle_property uicontextmenu; | |
7363 | 1793 |
1794 protected: | |
1795 std::map<caseless_str, property> all_props; | |
1796 | |
1797 protected: | |
1798 void insert_static_property (const std::string& name, base_property& p) | |
1799 { insert_property (name, property (&p, true)); } | |
1800 | |
1801 virtual void init (void) { } | |
6874 | 1802 }; |
1803 | |
7365 | 1804 class OCTINTERP_API base_graphics_object |
6874 | 1805 { |
1806 public: | |
1807 friend class graphics_object; | |
1808 | |
1809 base_graphics_object (void) : count (1) { } | |
1810 | |
1811 base_graphics_object (const base_graphics_object&) { } | |
1812 | |
1813 virtual ~base_graphics_object (void) { } | |
1814 | |
1815 virtual void mark_modified (void) | |
1816 { | |
7386 | 1817 if (valid_object ()) |
1818 get_properties ().mark_modified (); | |
1819 else | |
1820 error ("base_graphics_object::mark_modified: invalid graphics object"); | |
6874 | 1821 } |
1822 | |
7386 | 1823 virtual void override_defaults (base_graphics_object& obj) |
6874 | 1824 { |
7386 | 1825 if (valid_object ()) |
1826 get_properties ().override_defaults (obj); | |
1827 else | |
1828 error ("base_graphics_object::override_defaults: invalid graphics object"); | |
6874 | 1829 } |
1830 | |
7386 | 1831 virtual void set_from_list (property_list& plist) |
6874 | 1832 { |
7386 | 1833 if (valid_object ()) |
1834 get_properties ().set_from_list (*this, plist); | |
1835 else | |
1836 error ("base_graphics_object::set_from_list: invalid graphics object"); | |
6874 | 1837 } |
1838 | |
7386 | 1839 virtual void set (const caseless_str& pname, const octave_value& pval) |
6874 | 1840 { |
7386 | 1841 if (valid_object ()) |
1842 get_properties ().set (pname, pval); | |
1843 else | |
1844 error ("base_graphics_object::set: invalid graphics object"); | |
6874 | 1845 } |
1846 | |
1847 virtual void set_defaults (const std::string&) | |
1848 { | |
1849 error ("base_graphics_object::set_defaults: invalid graphics object"); | |
1850 } | |
1851 | |
7379 | 1852 virtual octave_value get (bool all = false) const |
6874 | 1853 { |
7386 | 1854 if (valid_object ()) |
1855 return get_properties ().get (all); | |
1856 else | |
1857 { | |
1858 error ("base_graphics_object::get: invalid graphics object"); | |
1859 return octave_value (); | |
1860 } | |
6874 | 1861 } |
1862 | |
7386 | 1863 virtual octave_value get (const caseless_str& pname) const |
6874 | 1864 { |
7386 | 1865 if (valid_object ()) |
1866 return get_properties ().get (pname); | |
1867 else | |
1868 { | |
1869 error ("base_graphics_object::get: invalid graphics object"); | |
1870 return octave_value (); | |
1871 } | |
6874 | 1872 } |
1873 | |
7189 | 1874 virtual octave_value get_default (const caseless_str&) const; |
6874 | 1875 |
7189 | 1876 virtual octave_value get_factory_default (const caseless_str&) const; |
6874 | 1877 |
1878 virtual octave_value get_defaults (void) const | |
1879 { | |
1880 error ("base_graphics_object::get_defaults: invalid graphics object"); | |
1881 return octave_value (); | |
1882 } | |
1883 | |
1884 virtual octave_value get_factory_defaults (void) const | |
1885 { | |
1886 error ("base_graphics_object::get_factory_defaults: invalid graphics object"); | |
1887 return octave_value (); | |
1888 } | |
1889 | |
1890 virtual graphics_handle get_parent (void) const | |
1891 { | |
7386 | 1892 if (valid_object ()) |
1893 return get_properties ().get_parent (); | |
1894 else | |
1895 { | |
1896 error ("base_graphics_object::get_parent: invalid graphics object"); | |
1897 return graphics_handle (); | |
1898 } | |
6874 | 1899 } |
1900 | |
7386 | 1901 virtual void remove_child (const graphics_handle& h) |
6874 | 1902 { |
7386 | 1903 if (valid_object ()) |
1904 get_properties ().remove_child (h); | |
1905 else | |
1906 error ("base_graphics_object::remove_child: invalid graphics object"); | |
6874 | 1907 } |
1908 | |
7386 | 1909 virtual void adopt (const graphics_handle& h) |
6874 | 1910 { |
7386 | 1911 if (valid_object ()) |
1912 get_properties ().adopt (h); | |
1913 else | |
1914 error ("base_graphics_object::adopt: invalid graphics object"); | |
6874 | 1915 } |
1916 | |
7386 | 1917 virtual void reparent (const graphics_handle& np) |
6874 | 1918 { |
7386 | 1919 if (valid_object ()) |
1920 get_properties ().reparent (np); | |
1921 else | |
1922 error ("base_graphics_object::reparent: invalid graphics object"); | |
6874 | 1923 } |
1924 | |
1925 virtual void defaults (void) const | |
1926 { | |
7386 | 1927 if (valid_object ()) |
1928 { | |
1929 std::string msg = (type () + "::defaults"); | |
1930 gripe_not_implemented (msg.c_str ()); | |
1931 } | |
1932 else | |
1933 error ("base_graphics_object::default: invalid graphics object"); | |
6874 | 1934 } |
1935 | |
1936 virtual base_properties& get_properties (void) | |
1937 { | |
1938 static base_properties properties; | |
1939 error ("base_graphics_object::get_properties: invalid graphics object"); | |
1940 return properties; | |
1941 } | |
1942 | |
7222 | 1943 virtual const base_properties& get_properties (void) const |
1944 { | |
1945 static base_properties properties; | |
1946 error ("base_graphics_object::get_properties: invalid graphics object"); | |
1947 return properties; | |
1948 } | |
1949 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
1950 virtual void update_axis_limits (const std::string& axis_type); |
7214 | 1951 |
6874 | 1952 virtual bool valid_object (void) const { return false; } |
1953 | |
7386 | 1954 virtual std::string type (void) const |
1955 { | |
1956 return (valid_object () ? get_properties ().graphics_object_name () | |
1957 : "unknown"); | |
1958 } | |
6874 | 1959 |
1960 bool isa (const std::string& go_name) const | |
1961 { | |
1962 return type () == go_name; | |
1963 } | |
1964 | |
7419 | 1965 virtual graphics_backend get_backend (void) const |
1966 { | |
1967 if (valid_object ()) | |
1968 return get_properties ().get_backend (); | |
1969 else | |
1970 { | |
1971 error ("base_graphics_object::get_backend: invalid graphics object"); | |
1972 return graphics_backend (); | |
1973 } | |
1974 } | |
1975 | |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1976 virtual void add_property_listener (const std::string& nm, |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1977 const octave_value& v, |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1978 listener_mode mode = POSTSET) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1979 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1980 if (valid_object ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1981 get_properties ().add_listener (nm, v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1982 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1983 |
6874 | 1984 protected: |
1985 // A reference count. | |
1986 int count; | |
1987 }; | |
1988 | |
7365 | 1989 class OCTINTERP_API graphics_object |
6874 | 1990 { |
1991 public: | |
1992 graphics_object (void) : rep (new base_graphics_object ()) { } | |
1993 | |
1994 graphics_object (base_graphics_object *new_rep) | |
1995 : rep (new_rep) { } | |
1996 | |
1997 graphics_object (const graphics_object& obj) | |
1998 { | |
1999 rep = obj.rep; | |
2000 rep->count++; | |
2001 } | |
2002 | |
2003 graphics_object& operator = (const graphics_object& obj) | |
2004 { | |
2005 if (rep != obj.rep) | |
2006 { | |
2007 if (--rep->count == 0) | |
2008 delete rep; | |
2009 | |
2010 rep = obj.rep; | |
2011 rep->count++; | |
2012 } | |
2013 | |
2014 return *this; | |
2015 } | |
2016 | |
2017 ~graphics_object (void) | |
2018 { | |
2019 if (--rep->count == 0) | |
2020 delete rep; | |
2021 } | |
2022 | |
2023 void mark_modified (void) { rep->mark_modified (); } | |
2024 | |
2025 void override_defaults (base_graphics_object& obj) | |
2026 { | |
2027 rep->override_defaults (obj); | |
2028 } | |
2029 | |
7214 | 2030 void set_from_list (property_list& plist) { rep->set_from_list (plist); } |
6874 | 2031 |
7189 | 2032 void set (const caseless_str& name, const octave_value& val) |
6874 | 2033 { |
2034 rep->set (name, val); | |
2035 } | |
2036 | |
2037 void set (const octave_value_list& args); | |
2038 | |
7214 | 2039 void set_defaults (const std::string& mode) { rep->set_defaults (mode); } |
2040 | |
7379 | 2041 octave_value get (bool all = false) const { return rep->get (all); } |
6874 | 2042 |
7189 | 2043 octave_value get (const caseless_str& name) const |
6874 | 2044 { |
2045 return name.compare ("default") | |
2046 ? get_defaults () | |
2047 : (name.compare ("factory") | |
2048 ? get_factory_defaults () : rep->get (name)); | |
2049 } | |
2050 | |
7189 | 2051 octave_value get_default (const caseless_str& name) const |
6874 | 2052 { |
2053 return rep->get_default (name); | |
2054 } | |
2055 | |
7189 | 2056 octave_value get_factory_default (const caseless_str& name) const |
6874 | 2057 { |
2058 return rep->get_factory_default (name); | |
2059 } | |
2060 | |
2061 octave_value get_defaults (void) const { return rep->get_defaults (); } | |
2062 | |
2063 octave_value get_factory_defaults (void) const | |
2064 { | |
2065 return rep->get_factory_defaults (); | |
2066 } | |
2067 | |
2068 graphics_handle get_parent (void) const { return rep->get_parent (); } | |
2069 | |
7214 | 2070 void remove_child (const graphics_handle& h) { rep->remove_child (h); } |
2071 | |
2072 void adopt (const graphics_handle& h) { rep->adopt (h); } | |
2073 | |
2074 void reparent (const graphics_handle& h) { rep->reparent (h); } | |
6874 | 2075 |
2076 void defaults (void) const { rep->defaults (); } | |
2077 | |
2078 bool isa (const std::string& go_name) const { return rep->isa (go_name); } | |
2079 | |
2080 base_properties& get_properties (void) { return rep->get_properties (); } | |
2081 | |
7222 | 2082 const base_properties& get_properties (void) const |
2083 { | |
2084 return rep->get_properties (); | |
2085 } | |
2086 | |
7214 | 2087 void update_axis_limits (const std::string& axis_type) |
2088 { | |
2089 rep->update_axis_limits (axis_type); | |
2090 } | |
2091 | |
6874 | 2092 bool valid_object (void) const { return rep->valid_object (); } |
2093 | |
2094 operator bool (void) const { return rep->valid_object (); } | |
2095 | |
7222 | 2096 // FIXME -- these functions should be generated automatically by the |
2097 // genprops.awk script. | |
2098 // | |
2099 // EMIT_GRAPHICS_OBJECT_GET_FUNCTIONS | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2100 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2101 octave_value get_xlim (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2102 { return get_properties ().get_xlim (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2103 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2104 octave_value get_ylim (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2105 { return get_properties ().get_ylim (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2106 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2107 octave_value get_zlim (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2108 { return get_properties ().get_zlim (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2109 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2110 octave_value get_clim (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2111 { return get_properties ().get_clim (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2112 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2113 octave_value get_alim (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2114 { return get_properties ().get_alim (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2115 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2116 bool is_xliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2117 { return get_properties ().is_xliminclude (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2118 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2119 bool is_yliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2120 { return get_properties ().is_yliminclude (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2121 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2122 bool is_zliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2123 { return get_properties ().is_zliminclude (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2124 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2125 bool is_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2126 { return get_properties ().is_climinclude (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2127 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2128 bool is_aliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2129 { return get_properties ().is_aliminclude (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2130 |
7419 | 2131 graphics_backend get_backend (void) const { return rep->get_backend (); } |
7408 | 2132 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2133 void add_property_listener (const std::string& nm, const octave_value& v, |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2134 listener_mode mode = POSTSET) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2135 { rep->add_property_listener (nm, v, mode); } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2136 |
7408 | 2137 private: |
7419 | 2138 base_graphics_object *rep; |
7408 | 2139 }; |
2140 | |
2141 // --------------------------------------------------------------------- | |
2142 | |
7365 | 2143 class OCTINTERP_API root_figure : public base_graphics_object |
6874 | 2144 { |
2145 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2146 class OCTINTERP_API properties : public base_properties |
6874 | 2147 { |
2148 public: | |
2149 // See the genprops.awk script for an explanation of the | |
2150 // properties declarations. | |
2151 | |
7363 | 2152 BEGIN_PROPERTIES(root_figure) |
2153 handle_property currentfigure S , graphics_handle () | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2154 handle_property callbackobject Sr , graphics_handle () |
6874 | 2155 END_PROPERTIES |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2156 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2157 private: |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2158 std::list<graphics_handle> cbo_stack; |
6874 | 2159 }; |
2160 | |
2161 private: | |
2162 properties xproperties; | |
2163 | |
2164 public: | |
2165 | |
7363 | 2166 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { } |
6874 | 2167 |
2168 ~root_figure (void) { xproperties.delete_children (); } | |
2169 | |
2170 void mark_modified (void) { } | |
2171 | |
2172 void override_defaults (base_graphics_object& obj) | |
2173 { | |
2174 // Now override with our defaults. If the default_properties | |
2175 // list includes the properties for all defaults (line, | |
2176 // surface, etc.) then we don't have to know the type of OBJ | |
2177 // here, we just call its set function and let it decide which | |
2178 // properties from the list to use. | |
2179 obj.set_from_list (default_properties); | |
2180 } | |
2181 | |
7189 | 2182 void set (const caseless_str& name, const octave_value& value) |
6874 | 2183 { |
2184 if (name.compare ("default", 7)) | |
2185 // strip "default", pass rest to function that will | |
2186 // parse the remainder and add the element to the | |
2187 // default_properties map. | |
2188 default_properties.set (name.substr (7), value); | |
2189 else | |
2190 xproperties.set (name, value); | |
2191 } | |
2192 | |
7189 | 2193 octave_value get (const caseless_str& name) const |
6874 | 2194 { |
2195 octave_value retval; | |
2196 | |
2197 if (name.compare ("default", 7)) | |
2198 return get_default (name.substr (7)); | |
2199 else if (name.compare ("factory", 7)) | |
2200 return get_factory_default (name.substr (7)); | |
2201 else | |
2202 retval = xproperties.get (name); | |
2203 | |
2204 return retval; | |
2205 } | |
2206 | |
7189 | 2207 octave_value get_default (const caseless_str& name) const |
6874 | 2208 { |
2209 octave_value retval = default_properties.lookup (name); | |
2210 | |
2211 if (retval.is_undefined ()) | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2212 { |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2213 // no default property found, use factory default |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2214 retval = factory_properties.lookup (name); |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2215 |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2216 if (retval.is_undefined ()) |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2217 error ("get: invalid default property `%s'", name.c_str ()); |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2218 } |
6874 | 2219 |
2220 return retval; | |
2221 } | |
2222 | |
7189 | 2223 octave_value get_factory_default (const caseless_str& name) const |
6874 | 2224 { |
2225 octave_value retval = factory_properties.lookup (name); | |
2226 | |
2227 if (retval.is_undefined ()) | |
2228 error ("get: invalid factory default property `%s'", name.c_str ()); | |
2229 | |
2230 return retval; | |
2231 } | |
2232 | |
2233 octave_value get_defaults (void) const | |
2234 { | |
2235 return default_properties.as_struct ("default"); | |
2236 } | |
2237 | |
2238 octave_value get_factory_defaults (void) const | |
2239 { | |
2240 return factory_properties.as_struct ("factory"); | |
2241 } | |
2242 | |
2243 base_properties& get_properties (void) { return xproperties; } | |
2244 | |
7222 | 2245 const base_properties& get_properties (void) const { return xproperties; } |
2246 | |
6874 | 2247 bool valid_object (void) const { return true; } |
2248 | |
2249 private: | |
2250 property_list default_properties; | |
2251 | |
2252 static property_list factory_properties; | |
2253 | |
2254 static property_list::plist_map_type init_factory_properties (void); | |
2255 }; | |
2256 | |
2257 // --------------------------------------------------------------------- | |
2258 | |
7365 | 2259 class OCTINTERP_API figure : public base_graphics_object |
6874 | 2260 { |
2261 public: | |
7445 | 2262 class OCTINTERP_API properties : public base_properties |
6874 | 2263 { |
2264 public: | |
7408 | 2265 void close (bool pop = true); |
2266 | |
7366 | 2267 void set_visible (const octave_value& val); |
6874 | 2268 |
7408 | 2269 graphics_backend get_backend (void) const |
2270 { | |
2271 if (! backend) | |
2272 backend = graphics_backend::default_backend (); | |
2273 | |
2274 return backend; | |
2275 } | |
2276 | |
7439 | 2277 void set_backend (const graphics_backend& b) |
2278 { | |
2279 close (false); | |
2280 backend = b; | |
2281 __backend__ = b.get_name (); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2282 __plot_stream__ = Matrix (); |
7439 | 2283 mark_modified (); |
2284 } | |
2285 | |
2286 void set___backend__ (const octave_value& val) | |
2287 { | |
2288 if (! error_state) | |
2289 { | |
2290 if (val.is_string ()) | |
2291 { | |
2292 std::string nm = val.string_value (); | |
2293 graphics_backend b = graphics_backend::find_backend (nm); | |
2294 if (b.get_name () != nm) | |
2295 { | |
2296 error ("figure::__backend__ : illegal backend"); | |
2297 } | |
2298 else | |
2299 { | |
2300 set_backend (b); | |
2301 mark_modified (); | |
2302 } | |
2303 } | |
2304 else | |
2305 error ("__backend__ must be a string"); | |
2306 } | |
2307 } | |
7408 | 2308 |
7447 | 2309 Matrix get_boundingbox (bool internal = false) const; |
7445 | 2310 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2311 void set_boundingbox (const Matrix& bb); |
7826
68550ad9ee9c
Add support for extern updaters. Add set_figure_position interface to graphics_backend.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7824
diff
changeset
|
2312 |
6874 | 2313 // See the genprops.awk script for an explanation of the |
2314 // properties declarations. | |
2315 | |
7363 | 2316 BEGIN_PROPERTIES(figure) |
7379 | 2317 any_property __plot_stream__ h , Matrix () |
2318 bool_property __enhanced__ h , "on" | |
7405 | 2319 radio_property nextplot , "new|{add}|replace_children|replace" |
7363 | 2320 callback_property closerequestfcn , "closereq" |
2321 handle_property currentaxes S , graphics_handle () | |
2322 array_property colormap , jet_colormap () | |
7405 | 2323 radio_property paperorientation , "{portrait}|landscape|rotated" |
7363 | 2324 color_property color , color_values (1, 1, 1) |
7405 | 2325 array_property alphamap , Matrix (64, 1, 1) |
2326 string_property currentcharacter r , "" | |
2327 handle_property currentobject r , graphics_handle () | |
2328 array_property current_point r , Matrix (2, 1, 0) | |
2329 bool_property dockcontrols , "off" | |
2330 bool_property doublebuffer , "on" | |
2331 string_property filename r , "" | |
2332 bool_property integerhandle , "on" | |
2333 bool_property inverthardcopy , "off" | |
2334 callback_property keypressfcn , Matrix () | |
2335 callback_property keyreleasefcn , Matrix () | |
2336 radio_property menubar , "none|{figure}" | |
2337 double_property mincolormap , 64 | |
2338 string_property name , "" | |
2339 bool_property numbertitle , "on" | |
2340 radio_property paperunits , "{inches}|centimeters|normalized|points" | |
2341 array_property paperposition , Matrix (1, 4 , 0) | |
2342 radio_property paperpositionmode , "auto|{manual}" | |
2343 array_property papersize r , Matrix (1, 4, 0) | |
2344 radio_property papertype , "{usletter}|uslegal|a0|a1|a2|a3|a4|a5|b0|b1|b2|b3|b4|b5|arch-a|arch-b|arch-c|arch-d|arch-e|a|b|c|d|e|tabloid" | |
2345 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand" | |
2346 array_property pointershapecdata , Matrix (16, 16, 0) | |
2347 array_property pointershapehotspot , Matrix (1, 2, 0) | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2348 array_property position S , default_figure_position () |
7405 | 2349 radio_property renderer , "{painters}|zbuffer|opengl|none" |
2350 radio_property renderermode , "{auto}|manual" | |
2351 bool_property resize , "on" | |
2352 callback_property resizefcn , Matrix () | |
2353 radio_property selectiontype , "{normal}|open|alt|extend" | |
2354 radio_property toolbar , "none|{auto}|figure" | |
2355 radio_property units , "inches|centimeters|normalized|points|{pixels}|characters" | |
2356 callback_property windowbuttondownfcn , Matrix () | |
2357 callback_property windowbuttonmotionfcn , Matrix () | |
2358 callback_property windowbuttonupfcn , Matrix () | |
2359 callback_property windowbuttonwheelfcn , Matrix () | |
2360 radio_property windowstyle , "{normal}|modal|docked" | |
2361 string_property wvisual , "" | |
2362 radio_property wvisualmode , "{auto}|manual" | |
2363 string_property xdisplay , "" | |
2364 string_property xvisual , "" | |
2365 radio_property xvisualmode , "{auto}|manual" | |
2366 callback_property buttondownfcn , Matrix () | |
7439 | 2367 string_property __backend__ s , "gnuplot" |
6874 | 2368 END_PROPERTIES |
7363 | 2369 |
2370 protected: | |
2371 void init (void) | |
2372 { | |
2373 colormap.add_constraint (dim_vector (-1, 3)); | |
7406 | 2374 alphamap.add_constraint (dim_vector (-1, 1)); |
2375 paperposition.add_constraint (dim_vector (1, 4)); | |
2376 pointershapecdata.add_constraint (dim_vector (16, 16)); | |
2377 pointershapehotspot.add_constraint (dim_vector (1, 2)); | |
2378 position.add_constraint (dim_vector (1, 4)); | |
7363 | 2379 } |
7408 | 2380 |
2381 private: | |
2382 mutable graphics_backend backend; | |
6874 | 2383 }; |
2384 | |
2385 private: | |
2386 properties xproperties; | |
2387 | |
2388 public: | |
2389 figure (const graphics_handle& mh, const graphics_handle& p) | |
2390 : base_graphics_object (), xproperties (mh, p), default_properties () | |
2391 { | |
2392 xproperties.override_defaults (*this); | |
2393 } | |
2394 | |
2395 ~figure (void) | |
2396 { | |
7386 | 2397 xproperties.delete_children (); |
6874 | 2398 xproperties.close (); |
2399 } | |
2400 | |
2401 void override_defaults (base_graphics_object& obj) | |
2402 { | |
2403 // Allow parent (root figure) to override first (properties knows how | |
2404 // to find the parent object). | |
2405 xproperties.override_defaults (obj); | |
2406 | |
2407 // Now override with our defaults. If the default_properties | |
2408 // list includes the properties for all defaults (line, | |
2409 // surface, etc.) then we don't have to know the type of OBJ | |
2410 // here, we just call its set function and let it decide which | |
2411 // properties from the list to use. | |
2412 obj.set_from_list (default_properties); | |
2413 } | |
2414 | |
7189 | 2415 void set (const caseless_str& name, const octave_value& value) |
6874 | 2416 { |
2417 if (name.compare ("default", 7)) | |
2418 // strip "default", pass rest to function that will | |
2419 // parse the remainder and add the element to the | |
2420 // default_properties map. | |
2421 default_properties.set (name.substr (7), value); | |
2422 else | |
2423 xproperties.set (name, value); | |
2424 } | |
2425 | |
7189 | 2426 octave_value get (const caseless_str& name) const |
6874 | 2427 { |
2428 octave_value retval; | |
2429 | |
2430 if (name.compare ("default", 7)) | |
2431 retval = get_default (name.substr (7)); | |
2432 else | |
2433 retval = xproperties.get (name); | |
2434 | |
2435 return retval; | |
2436 } | |
2437 | |
7189 | 2438 octave_value get_default (const caseless_str& name) const; |
6874 | 2439 |
2440 octave_value get_defaults (void) const | |
2441 { | |
2442 return default_properties.as_struct ("default"); | |
2443 } | |
2444 | |
2445 base_properties& get_properties (void) { return xproperties; } | |
2446 | |
7222 | 2447 const base_properties& get_properties (void) const { return xproperties; } |
2448 | |
6874 | 2449 bool valid_object (void) const { return true; } |
2450 | |
2451 private: | |
2452 property_list default_properties; | |
2453 }; | |
2454 | |
2455 // --------------------------------------------------------------------- | |
2456 | |
7435 | 2457 class OCTINTERP_API graphics_xform |
2458 { | |
2459 public: | |
2460 graphics_xform (void) | |
2461 : xform (xform_eye ()), xform_inv (xform_eye ()) | |
2462 { | |
2463 sx = sy = sz = "linear"; | |
2464 } | |
2465 | |
2466 graphics_xform (const Matrix& xm, const Matrix& xim, | |
2467 const scaler& x, const scaler& y, const scaler& z) | |
2468 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z) { } | |
2469 | |
2470 graphics_xform (const graphics_xform& g) | |
2471 : xform (g.xform), xform_inv (g.xform_inv), sx (g.sx), | |
2472 sy (g.sy), sz (g.sz) { } | |
2473 | |
2474 ~graphics_xform (void) { } | |
2475 | |
2476 graphics_xform& operator = (const graphics_xform& g) | |
2477 { | |
2478 xform = g.xform; | |
2479 xform_inv = g.xform_inv; | |
2480 sx = g.sx; | |
2481 sy = g.sy; | |
2482 sz = g.sz; | |
2483 | |
2484 return *this; | |
2485 } | |
2486 | |
2487 static ColumnVector xform_vector (double x, double y, double z); | |
2488 | |
2489 static Matrix xform_eye (void); | |
2490 | |
2491 ColumnVector transform (double x, double y, double z, | |
2492 bool scale = true) const; | |
2493 | |
2494 ColumnVector untransform (double x, double y, double z, | |
2495 bool scale = true) const; | |
2496 | |
2497 Matrix xscale (const Matrix& m) const { return sx.scale (m); } | |
2498 Matrix yscale (const Matrix& m) const { return sy.scale (m); } | |
2499 Matrix zscale (const Matrix& m) const { return sz.scale (m); } | |
2500 | |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2501 Matrix scale (const Matrix& m) const |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2502 { |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2503 bool has_z = (m.columns () > 2); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2504 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2505 if (sx.is_linear () && sy.is_linear () |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2506 && (! has_z || sz.is_linear ())) |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2507 return m; |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2508 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2509 Matrix retval (m.dims ()); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2510 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2511 int r = m.rows (); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2512 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2513 for (int i = 0; i < r; i++) |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2514 { |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2515 retval(i,0) = sx.scale (m(i,0)); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2516 retval(i,1) = sy.scale (m(i,1)); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2517 if (has_z) |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2518 retval(i,2) = sz.scale (m(i,2)); |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2519 } |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2520 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2521 return retval; |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2522 } |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2523 |
7435 | 2524 private: |
2525 Matrix xform; | |
2526 Matrix xform_inv; | |
2527 scaler sx, sy, sz; | |
2528 }; | |
2529 | |
7365 | 2530 class OCTINTERP_API axes : public base_graphics_object |
6874 | 2531 { |
2532 public: | |
7445 | 2533 class OCTINTERP_API properties : public base_properties |
6874 | 2534 { |
2535 public: | |
2536 void set_defaults (base_graphics_object& obj, const std::string& mode); | |
2537 | |
2538 void remove_child (const graphics_handle& h); | |
2539 | |
2540 void delete_children (void); | |
2541 | |
7427 | 2542 const scaler& get_x_scaler (void) const { return sx; } |
2543 const scaler& get_y_scaler (void) const { return sy; } | |
2544 const scaler& get_z_scaler (void) const { return sz; } | |
2545 | |
7447 | 2546 Matrix get_boundingbox (bool internal = false) const; |
7427 | 2547 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2548 void update_boundingbox (void) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2549 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2550 if (units_is ("normalized")) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2551 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2552 update_transform (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2553 base_properties::update_boundingbox (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2554 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2555 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2556 |
7427 | 2557 void update_camera (void); |
2558 void update_aspectratios (void); | |
2559 void update_transform (void) | |
2560 { | |
2561 update_aspectratios (); | |
2562 update_camera (); | |
2563 } | |
2564 | |
7435 | 2565 graphics_xform get_transform (void) const |
2566 { return graphics_xform (x_render, x_render_inv, sx, sy, sz); } | |
2567 | |
2568 Matrix get_transform_matrix (void) const { return x_render; } | |
2569 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; } | |
2570 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; } | |
2571 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; } | |
2572 Matrix get_transform_zlim (void) const { return x_zlim; } | |
2573 | |
7842
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2574 ColumnVector pixel2coord (double px, double py) const |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2575 { return get_transform ().untransform (px, py, (x_zlim(0)+x_zlim(1))/2); } |
7842
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2576 |
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2577 ColumnVector coord2pixel (double x, double y, double z) const |
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2578 { return get_transform ().transform (x, y, z); } |
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2579 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2580 void zoom (const Matrix& xl, const Matrix& yl); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2581 void unzoom (void); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2582 void clear_zoom_stack (void); |
7842
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2583 |
7427 | 2584 private: |
2585 scaler sx, sy, sz; | |
2586 Matrix x_render, x_render_inv; | |
2587 Matrix x_gl_mat1, x_gl_mat2; | |
2588 Matrix x_zlim; | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2589 std::list<octave_value> zoom_stack; |
7427 | 2590 |
6874 | 2591 // See the genprops.awk script for an explanation of the |
2592 // properties declarations. | |
2593 | |
7363 | 2594 BEGIN_PROPERTIES(axes) |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2595 array_property position u , default_axes_position () |
7363 | 2596 mutable handle_property title GSO , graphics_handle () |
2597 bool_property box , "on" | |
2598 bool_property key , "off" | |
2599 bool_property keybox , "off" | |
2600 double_property keypos , 1 | |
2601 array_property colororder , default_colororder () | |
2602 array_property dataaspectratio m , Matrix (1, 3, 1.0) | |
2603 radio_property dataaspectratiomode , "{auto}|manual" | |
7379 | 2604 radio_property layer , "{bottom}|top" |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2605 row_vector_property xlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2606 row_vector_property ylim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2607 row_vector_property zlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2608 row_vector_property clim m , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2609 row_vector_property alim m , default_lim () |
7363 | 2610 radio_property xlimmode al , "{auto}|manual" |
2611 radio_property ylimmode al , "{auto}|manual" | |
2612 radio_property zlimmode al , "{auto}|manual" | |
2613 radio_property climmode al , "{auto}|manual" | |
7403 | 2614 radio_property alimmode , "{auto}|manual" |
7363 | 2615 mutable handle_property xlabel GSO , graphics_handle () |
2616 mutable handle_property ylabel GSO , graphics_handle () | |
2617 mutable handle_property zlabel GSO , graphics_handle () | |
2618 bool_property xgrid , "off" | |
2619 bool_property ygrid , "off" | |
2620 bool_property zgrid , "off" | |
2621 bool_property xminorgrid , "off" | |
2622 bool_property yminorgrid , "off" | |
2623 bool_property zminorgrid , "off" | |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2624 row_vector_property xtick m , Matrix () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2625 row_vector_property ytick m , Matrix () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2626 row_vector_property ztick m , Matrix () |
7363 | 2627 radio_property xtickmode , "{auto}|manual" |
2628 radio_property ytickmode , "{auto}|manual" | |
2629 radio_property ztickmode , "{auto}|manual" | |
7403 | 2630 bool_property xminortick , "off" |
2631 bool_property yminortick , "off" | |
2632 bool_property zminortick , "off" | |
2633 // FIXME: should be kind of string array | |
7363 | 2634 any_property xticklabel m , "" |
2635 any_property yticklabel m , "" | |
2636 any_property zticklabel m , "" | |
2637 radio_property xticklabelmode , "{auto}|manual" | |
2638 radio_property yticklabelmode , "{auto}|manual" | |
2639 radio_property zticklabelmode , "{auto}|manual" | |
7379 | 2640 color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) |
7363 | 2641 color_property xcolor , color_values (0, 0, 0) |
2642 color_property ycolor , color_values (0, 0, 0) | |
2643 color_property zcolor , color_values (0, 0, 0) | |
7427 | 2644 radio_property xscale alu , "{linear}|log" |
2645 radio_property yscale alu , "{linear}|log" | |
2646 radio_property zscale alu , "{linear}|log" | |
2647 radio_property xdir u , "{normal}|reverse" | |
2648 radio_property ydir u , "{normal}|reverse" | |
2649 radio_property zdir u , "{normal}|reverse" | |
7365 | 2650 radio_property yaxislocation , "{left}|right|zero" |
2651 radio_property xaxislocation , "{bottom}|top|zero" | |
7427 | 2652 array_property view u , Matrix () |
7363 | 2653 radio_property nextplot , "add|replace_children|{replace}" |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2654 array_property outerposition u , default_axes_outerposition () |
7379 | 2655 radio_property activepositionproperty , "{outerposition}|position" |
2656 radio_property __colorbar__ h , "{none}|north|south|east|west|northoutside|southoutside|eastoutside|westoutside" | |
7403 | 2657 color_property ambientlightcolor , color_values (1, 1, 1) |
2658 array_property cameraposition m , Matrix (1, 3, 0.0) | |
2659 array_property cameratarget m , Matrix (1, 3, 0.0) | |
2660 array_property cameraupvector m , Matrix () | |
2661 double_property cameraviewangle m , 10.0 | |
2662 radio_property camerapositionmode , "{auto}|manual" | |
2663 radio_property cameratargetmode , "{auto}|manual" | |
2664 radio_property cameraupvectormode , "{auto}|manual" | |
2665 radio_property cameraviewanglemode , "{auto}|manual" | |
2666 array_property currentpoint , Matrix (2, 3, 0.0) | |
2667 radio_property drawmode , "{normal}|fast" | |
2668 radio_property fontangle , "{normal}|italic|oblique" | |
2669 string_property fontname , "Helvetica" | |
2670 double_property fontsize , 12 | |
2671 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels" | |
2672 radio_property fontweight , "{normal}|light|demi|bold" | |
7445 | 2673 radio_property gridlinestyle , "-|--|{:}|-.|none" |
7403 | 2674 // FIXME: should be kind of string array |
2675 string_property linestyleorder , "-" | |
2676 double_property linewidth , 0.5 | |
7445 | 2677 radio_property minorgridlinestyle , "-|--|{:}|-.|none" |
7403 | 2678 array_property plotboxaspectratio m , Matrix (1, 3, 1.0) |
2679 radio_property plotboxaspectratiomode , "{auto}|manual" | |
2680 radio_property projection , "{orthographic}|perpective" | |
2681 radio_property tickdir m , "{in}|out" | |
2682 radio_property tickdirmode , "{auto}|manual" | |
2683 array_property ticklength , Matrix (1, 2, 0.1) | |
2684 array_property tightinset r , Matrix (1, 4, 0.0) | |
2685 // FIXME: uicontextmenu should be moved here | |
2686 radio_property units , "{normalized}|inches|centimeters|points|pixels|characters" | |
2687 // hidden properties for transformation computation | |
2688 array_property x_viewtransform h , Matrix (4, 4, 0.0) | |
2689 array_property x_projectiontransform h , Matrix (4, 4, 0.0) | |
2690 array_property x_viewporttransform h , Matrix (4, 4, 0.0) | |
2691 array_property x_normrendertransform h , Matrix (4, 4, 0.0) | |
2692 array_property x_rendertransform h , Matrix (4, 4, 0.0) | |
7189 | 2693 END_PROPERTIES |
6874 | 2694 |
7363 | 2695 protected: |
2696 void init (void) | |
2697 { | |
2698 position.add_constraint (dim_vector (1, 4)); | |
7403 | 2699 position.add_constraint (dim_vector (0, 0)); |
7363 | 2700 outerposition.add_constraint (dim_vector (1, 4)); |
2701 colororder.add_constraint (dim_vector (-1, 3)); | |
2702 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
7403 | 2703 plotboxaspectratio.add_constraint (dim_vector (1, 3)); |
7527
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2704 xlim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2705 ylim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2706 zlim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2707 clim.add_constraint (2); |
d219e712c20e
make row_vector_property work?
John W. Eaton <jwe@octave.org>
parents:
7526
diff
changeset
|
2708 alim.add_constraint (2); |
7363 | 2709 xtick.add_constraint (dim_vector (1, -1)); |
2710 ytick.add_constraint (dim_vector (1, -1)); | |
2711 ztick.add_constraint (dim_vector (1, -1)); | |
2712 Matrix vw (1, 2, 0); | |
2713 vw(1) = 90; | |
2714 view = vw; | |
2715 view.add_constraint (dim_vector (1, 2)); | |
7403 | 2716 cameraposition.add_constraint (dim_vector (1, 3)); |
2717 Matrix upv (1, 3, 0.0); | |
2718 upv(2) = 1.0; | |
2719 cameraupvector = upv; | |
2720 cameraupvector.add_constraint (dim_vector (1, 3)); | |
2721 currentpoint.add_constraint (dim_vector (2, 3)); | |
2722 ticklength.add_constraint (dim_vector (1, 2)); | |
2723 tightinset.add_constraint (dim_vector (1, 4)); | |
7427 | 2724 |
2725 x_zlim.resize (1, 2); | |
2726 sx = "linear"; | |
2727 sy = "linear"; | |
2728 sz = "linear"; | |
7363 | 2729 } |
7427 | 2730 |
2731 private: | |
2732 void update_xscale (void) { sx = get_xscale (); } | |
2733 void update_yscale (void) { sy = get_yscale (); } | |
2734 void update_zscale (void) { sz = get_zscale (); } | |
2735 | |
2736 void update_view (void) { update_camera (); } | |
2737 | |
2738 void update_xdir (void) { update_camera (); } | |
2739 void update_ydir (void) { update_camera (); } | |
2740 void update_zdir (void) { update_camera (); } | |
7446 | 2741 |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2742 void sync_positions (void); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2743 void update_outerposition (void) { sync_positions ();} |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2744 void update_position (void) { sync_positions (); } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7857
diff
changeset
|
2745 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7826
diff
changeset
|
2746 double calc_tick_sep (double minval, double maxval); |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
2747 void calc_ticks_and_lims (array_property& lims, array_property& ticks, bool limmode_is_auto, bool is_logscale); |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2748 void fix_limits (array_property& lims) |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2749 { |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2750 if (lims.get ().is_empty ()) |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2751 return; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2752 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2753 Matrix l = lims.get ().matrix_value (); |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2754 if (l(0) > l(1)) |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2755 { |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2756 l(0) = 0; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2757 l(1) = 1; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2758 lims = l; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2759 } |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2760 else if (l(0) == l(1)) |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2761 { |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2762 l(0) -= 0.5; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2763 l(1) += 0.5; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2764 lims = l; |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2765 } |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2766 } |
7446 | 2767 |
2768 public: | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7826
diff
changeset
|
2769 Matrix get_axis_limits (double xmin, double xmax, double min_pos, bool logscale); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2770 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2771 void update_xlim (bool do_clr_zoom = true) |
7446 | 2772 { |
2773 if (xtickmode.is ("auto")) | |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
2774 calc_ticks_and_lims (xlim, xtick, xlimmode.is ("auto"), xscale.is ("log")); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2775 |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2776 fix_limits (xlim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2777 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2778 if (do_clr_zoom) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2779 zoom_stack.clear (); |
7446 | 2780 } |
2781 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2782 void update_ylim (bool do_clr_zoom = true) |
7446 | 2783 { |
2784 if (ytickmode.is ("auto")) | |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
2785 calc_ticks_and_lims (ylim, ytick, ylimmode.is ("auto"), yscale.is ("log")); |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2786 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2787 fix_limits (ylim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2788 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2789 if (do_clr_zoom) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2790 zoom_stack.clear (); |
7446 | 2791 } |
2792 | |
2793 void update_zlim (void) | |
2794 { | |
2795 if (ztickmode.is ("auto")) | |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
2796 calc_ticks_and_lims (zlim, ztick, zlimmode.is ("auto"), zscale.is ("log")); |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2797 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
2798 fix_limits (zlim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2799 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2800 zoom_stack.clear (); |
7446 | 2801 } |
2802 | |
6874 | 2803 }; |
2804 | |
2805 private: | |
2806 properties xproperties; | |
2807 | |
2808 public: | |
2809 axes (const graphics_handle& mh, const graphics_handle& p) | |
2810 : base_graphics_object (), xproperties (mh, p), default_properties () | |
2811 { | |
2812 xproperties.override_defaults (*this); | |
7830
61aee739a4da
Make sure to initialize axes xform data.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
2813 xproperties.update_transform (); |
6874 | 2814 } |
2815 | |
2816 ~axes (void) { xproperties.delete_children (); } | |
2817 | |
2818 void override_defaults (base_graphics_object& obj) | |
2819 { | |
2820 // Allow parent (figure) to override first (properties knows how | |
2821 // to find the parent object). | |
2822 xproperties.override_defaults (obj); | |
2823 | |
2824 // Now override with our defaults. If the default_properties | |
2825 // list includes the properties for all defaults (line, | |
2826 // surface, etc.) then we don't have to know the type of OBJ | |
2827 // here, we just call its set function and let it decide which | |
2828 // properties from the list to use. | |
2829 obj.set_from_list (default_properties); | |
2830 } | |
2831 | |
7189 | 2832 void set (const caseless_str& name, const octave_value& value) |
6874 | 2833 { |
2834 if (name.compare ("default", 7)) | |
2835 // strip "default", pass rest to function that will | |
2836 // parse the remainder and add the element to the | |
2837 // default_properties map. | |
2838 default_properties.set (name.substr (7), value); | |
2839 else | |
2840 xproperties.set (name, value); | |
2841 } | |
2842 | |
2843 void set_defaults (const std::string& mode) | |
2844 { | |
2845 xproperties.set_defaults (*this, mode); | |
2846 } | |
2847 | |
7189 | 2848 octave_value get (const caseless_str& name) const |
6874 | 2849 { |
2850 octave_value retval; | |
2851 | |
2852 // FIXME -- finish this. | |
2853 if (name.compare ("default", 7)) | |
2854 retval = get_default (name.substr (7)); | |
2855 else | |
2856 retval = xproperties.get (name); | |
2857 | |
2858 return retval; | |
2859 } | |
2860 | |
7189 | 2861 octave_value get_default (const caseless_str& name) const; |
6874 | 2862 |
2863 octave_value get_defaults (void) const | |
2864 { | |
2865 return default_properties.as_struct ("default"); | |
2866 } | |
2867 | |
2868 base_properties& get_properties (void) { return xproperties; } | |
2869 | |
7222 | 2870 const base_properties& get_properties (void) const { return xproperties; } |
2871 | |
7214 | 2872 void update_axis_limits (const std::string& axis_type); |
2873 | |
6874 | 2874 bool valid_object (void) const { return true; } |
2875 | |
2876 private: | |
2877 property_list default_properties; | |
2878 }; | |
2879 | |
2880 // --------------------------------------------------------------------- | |
2881 | |
7365 | 2882 class OCTINTERP_API line : public base_graphics_object |
6874 | 2883 { |
2884 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2885 class OCTINTERP_API properties : public base_properties |
6874 | 2886 { |
2887 public: | |
2888 // See the genprops.awk script for an explanation of the | |
2889 // properties declarations. | |
2890 | |
7366 | 2891 // properties which are not in matlab: |
7384 | 2892 // ldata, udata, xldata, xudata, keylabel, interpreter |
7366 | 2893 |
7363 | 2894 BEGIN_PROPERTIES(line) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2895 row_vector_property xdata u , default_data () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2896 row_vector_property ydata u , default_data () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2897 row_vector_property zdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2898 row_vector_property ldata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2899 row_vector_property udata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2900 row_vector_property xldata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2901 row_vector_property xudata u , Matrix () |
7363 | 2902 color_property color , color_values (0, 0, 0) |
2903 radio_property linestyle , "{-}|--|:|-.|none" | |
2904 double_property linewidth , 0.5 | |
2905 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
2906 color_property markeredgecolor , "{auto}|none" | |
2907 color_property markerfacecolor , "auto|{none}" | |
2908 double_property markersize , 6 | |
2909 string_property keylabel , "" | |
7384 | 2910 radio_property interpreter , "{tex}|none|latex" |
7377 | 2911 string_property displayname , "" |
7380 | 2912 radio_property erasemode , "{normal}|none|xor|background" |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2913 // hidden properties for limit computation |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2914 row_vector_property xlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2915 row_vector_property ylim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2916 row_vector_property zlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2917 bool_property xliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2918 bool_property yliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2919 bool_property zliminclude hl , "off" |
6874 | 2920 END_PROPERTIES |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2921 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2922 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2923 Matrix compute_xlim (void) const; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2924 Matrix compute_ylim (void) const; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2925 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2926 void update_xdata (void) { set_xlim (compute_xlim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2927 void update_xldata (void) { set_xlim (compute_xlim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2928 void update_xudata (void) { set_xlim (compute_xlim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2929 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2930 void update_ydata (void) { set_ylim (compute_ylim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2931 void update_ldata (void) { set_ylim (compute_ylim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2932 void update_udata (void) { set_ylim (compute_ylim ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2933 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2934 void update_zdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2935 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2936 set_zlim (zdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2937 set_zliminclude (get_zdata ().numel () > 0); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2938 } |
6874 | 2939 }; |
2940 | |
2941 private: | |
2942 properties xproperties; | |
2943 | |
2944 public: | |
2945 line (const graphics_handle& mh, const graphics_handle& p) | |
2946 : base_graphics_object (), xproperties (mh, p) | |
2947 { | |
2948 xproperties.override_defaults (*this); | |
2949 } | |
2950 | |
2951 ~line (void) { xproperties.delete_children (); } | |
2952 | |
2953 base_properties& get_properties (void) { return xproperties; } | |
2954 | |
7222 | 2955 const base_properties& get_properties (void) const { return xproperties; } |
2956 | |
6874 | 2957 bool valid_object (void) const { return true; } |
2958 }; | |
2959 | |
2960 // --------------------------------------------------------------------- | |
2961 | |
7365 | 2962 class OCTINTERP_API text : public base_graphics_object |
6874 | 2963 { |
2964 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2965 class OCTINTERP_API properties : public base_properties |
6874 | 2966 { |
2967 public: | |
2968 // See the genprops.awk script for an explanation of the | |
2969 // properties declarations. | |
2970 | |
7363 | 2971 BEGIN_PROPERTIES(text) |
2972 string_property string , "" | |
2973 radio_property units , "{data}|pixels|normalized|inches|centimeters|points" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2974 array_property position u , Matrix (1, 3, 0.0) |
7363 | 2975 double_property rotation , 0 |
2976 radio_property horizontalalignment , "{left}|center|right" | |
2977 color_property color , color_values (0, 0, 0) | |
2978 string_property fontname , "Helvetica" | |
2979 double_property fontsize , 10 | |
7379 | 2980 radio_property fontangle , "{normal}|italic|oblique" |
2981 radio_property fontweight , "light|{normal}|demi|bold" | |
2982 radio_property interpreter , "{tex}|none|latex" | |
7377 | 2983 color_property backgroundcolor , "{none}" |
2984 string_property displayname , "" | |
2985 color_property edgecolor , "{none}" | |
7380 | 2986 radio_property erasemode , "{normal}|none|xor|background" |
7377 | 2987 bool_property editing , "off" |
2988 radio_property fontunits , "inches|centimeters|normalized|{points}|pixel" | |
2989 radio_property linestyle , "{-}|--|:|-.|none" | |
2990 double_property linewidth , 0.5 | |
2991 double_property margin , 1 | |
2992 radio_property verticalalignment , "top|cap|{middle}|baseline|bottom" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2993 // hidden properties for limit computation |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2994 row_vector_property xlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2995 row_vector_property ylim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2996 row_vector_property zlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2997 bool_property xliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2998 bool_property yliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2999 bool_property zliminclude hl , "off" |
6874 | 3000 END_PROPERTIES |
3001 | |
7363 | 3002 protected: |
3003 void init (void) | |
3004 { | |
3005 position.add_constraint (dim_vector (1, 3)); | |
3006 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3007 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3008 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3009 void update_position (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3010 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3011 Matrix pos = get_position ().matrix_value (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3012 Matrix lim; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3013 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3014 lim = Matrix (1, 3, pos(0)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3015 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3016 set_xlim (lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3017 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3018 lim = Matrix (1, 3, pos(1)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3019 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3020 set_ylim (lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3021 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3022 if (pos.numel () == 3) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3023 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3024 lim = Matrix (1, 3, pos(2)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3025 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3026 set_zliminclude ("on"); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3027 set_zlim (lim); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3028 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3029 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3030 set_zliminclude ("off"); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3031 } |
6874 | 3032 }; |
3033 | |
3034 private: | |
3035 properties xproperties; | |
3036 | |
3037 public: | |
3038 text (const graphics_handle& mh, const graphics_handle& p) | |
3039 : base_graphics_object (), xproperties (mh, p) | |
3040 { | |
3041 xproperties.override_defaults (*this); | |
3042 } | |
3043 | |
3044 ~text (void) { xproperties.delete_children (); } | |
3045 | |
3046 base_properties& get_properties (void) { return xproperties; } | |
3047 | |
7222 | 3048 const base_properties& get_properties (void) const { return xproperties; } |
3049 | |
6874 | 3050 bool valid_object (void) const { return true; } |
3051 }; | |
3052 | |
3053 // --------------------------------------------------------------------- | |
3054 | |
7365 | 3055 class OCTINTERP_API image : public base_graphics_object |
6874 | 3056 { |
3057 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3058 class OCTINTERP_API properties : public base_properties |
6874 | 3059 { |
3060 public: | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3061 bool is_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3062 { return (climinclude.is_on () && cdatamapping.is ("scaled")); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3063 std::string get_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3064 { return climinclude.current_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3065 |
6874 | 3066 // See the genprops.awk script for an explanation of the |
3067 // properties declarations. | |
3068 | |
7363 | 3069 BEGIN_PROPERTIES(image) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3070 row_vector_property xdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3071 row_vector_property ydata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3072 array_property cdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3073 radio_property cdatamapping al , "{scaled}|direct" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3074 // hidden properties for limit computation |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3075 row_vector_property xlim hlr , Matrix() |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3076 row_vector_property ylim hlr , Matrix() |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3077 row_vector_property clim hlr , Matrix() |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3078 bool_property xliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3079 bool_property yliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3080 bool_property climinclude hlg , "on" |
6874 | 3081 END_PROPERTIES |
3082 | |
7363 | 3083 protected: |
3084 void init (void) | |
3085 { | |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3086 xdata.add_constraint (2); |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3087 ydata.add_constraint (2); |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3088 cdata.add_constraint ("double"); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3089 cdata.add_constraint ("uint8"); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3090 cdata.add_constraint (dim_vector (-1, -1)); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3091 cdata.add_constraint (dim_vector (-1, -1, 3)); |
7363 | 3092 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3093 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3094 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3095 // FIXME: limits should take pixel width into account |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3096 void update_xdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3097 { set_xlim (xdata.get_limits ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3098 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3099 // FIXME: idem |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3100 void update_ydata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3101 { set_ylim (ydata.get_limits ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3102 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3103 void update_cdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3104 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3105 if (cdatamapping_is ("scaled")) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3106 set_clim (cdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3107 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3108 clim = cdata.get_limits (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3109 } |
6874 | 3110 }; |
3111 | |
3112 private: | |
3113 properties xproperties; | |
3114 | |
3115 public: | |
3116 image (const graphics_handle& mh, const graphics_handle& p) | |
3117 : base_graphics_object (), xproperties (mh, p) | |
3118 { | |
3119 xproperties.override_defaults (*this); | |
3120 } | |
3121 | |
3122 ~image (void) { xproperties.delete_children (); } | |
3123 | |
3124 base_properties& get_properties (void) { return xproperties; } | |
3125 | |
7222 | 3126 const base_properties& get_properties (void) const { return xproperties; } |
3127 | |
6874 | 3128 bool valid_object (void) const { return true; } |
3129 }; | |
3130 | |
3131 // --------------------------------------------------------------------- | |
3132 | |
7365 | 3133 class OCTINTERP_API patch : public base_graphics_object |
6874 | 3134 { |
3135 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3136 class OCTINTERP_API properties : public base_properties |
6874 | 3137 { |
3138 public: | |
7833
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7832
diff
changeset
|
3139 octave_value get_color_data (void) const; |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7832
diff
changeset
|
3140 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3141 bool is_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3142 { return (climinclude.is_on () && cdatamapping.is ("scaled")); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3143 std::string get_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3144 { return climinclude.current_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3145 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3146 bool is_aliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3147 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3148 std::string get_aliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3149 { return aliminclude.current_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3150 |
6874 | 3151 // See the genprops.awk script for an explanation of the |
3152 // properties declarations. | |
3153 | |
7363 | 3154 BEGIN_PROPERTIES(patch) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3155 array_property xdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3156 array_property ydata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3157 array_property zdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3158 array_property cdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3159 radio_property cdatamapping l , "{scaled}|direct" |
7363 | 3160 array_property faces , Matrix () |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3161 array_property facevertexalphadata , Matrix () |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3162 array_property facevertexcdata , Matrix () |
7363 | 3163 array_property vertices , Matrix () |
7368 | 3164 array_property vertexnormals , Matrix () |
7379 | 3165 radio_property normalmode , "{auto}|manual" |
3166 color_property facecolor , "{flat}|none|interp" | |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7842
diff
changeset
|
3167 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
3168 radio_property facelighting , "flat|{none}|gouraud|phong" |
7379 | 3169 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3170 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7379 | 3171 radio_property edgelighting , "{none}|flat|gouraud|phong" |
3172 radio_property backfacelighting , "{reverselit}|unlit|lit" | |
7368 | 3173 double_property ambientstrength , 0.3 |
3174 double_property diffusestrength , 0.6 | |
3175 double_property specularstrength , 0.6 | |
3176 double_property specularexponent , 10.0 | |
3177 double_property specularcolorreflectance , 1.0 | |
7379 | 3178 radio_property erasemode , "{normal}|background|xor|none" |
7363 | 3179 radio_property linestyle , "{-}|--|:|-.|none" |
3180 double_property linewidth , 0.5 | |
3181 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
3182 color_property markeredgecolor , "{auto}|none" | |
3183 color_property markerfacecolor , "auto|{none}" | |
3184 double_property markersize , 6 | |
3185 string_property keylabel , "" | |
7384 | 3186 radio_property interpreter , "{tex}|none|latex" |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3187 radio_property alphadatamapping l , "none|{scaled}|direct" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3188 // hidden properties for limit computation |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3189 row_vector_property xlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3190 row_vector_property ylim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3191 row_vector_property zlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3192 row_vector_property clim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3193 row_vector_property alim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3194 bool_property xliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3195 bool_property yliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3196 bool_property zliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3197 bool_property climinclude hlg , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3198 bool_property aliminclude hlg , "on" |
6874 | 3199 END_PROPERTIES |
3200 | |
7363 | 3201 protected: |
3202 void init (void) | |
3203 { | |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3204 xdata.add_constraint (dim_vector (-1, -1)); |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3205 ydata.add_constraint (dim_vector (-1, -1)); |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3206 zdata.add_constraint (dim_vector (-1, -1)); |
7363 | 3207 vertices.add_constraint (dim_vector (-1, 2)); |
3208 vertices.add_constraint (dim_vector (-1, 3)); | |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3209 cdata.add_constraint (dim_vector (-1, -1)); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3210 cdata.add_constraint (dim_vector (-1, -1, 3)); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3211 facevertexcdata.add_constraint (dim_vector (-1, 1)); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3212 facevertexcdata.add_constraint (dim_vector (-1, 3)); |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3213 facevertexalphadata.add_constraint (dim_vector (-1, 1)); |
7363 | 3214 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3215 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3216 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3217 void update_xdata (void) { set_xlim (xdata.get_limits ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3218 void update_ydata (void) { set_ylim (ydata.get_limits ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3219 void update_zdata (void) { set_zlim (zdata.get_limits ()); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3220 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3221 void update_cdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3222 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3223 if (cdatamapping_is ("scaled")) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3224 set_clim (cdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3225 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3226 clim = cdata.get_limits (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3227 } |
6874 | 3228 }; |
3229 | |
3230 private: | |
3231 properties xproperties; | |
3232 | |
3233 public: | |
3234 patch (const graphics_handle& mh, const graphics_handle& p) | |
3235 : base_graphics_object (), xproperties (mh, p) | |
3236 { | |
3237 xproperties.override_defaults (*this); | |
3238 } | |
3239 | |
3240 ~patch (void) { xproperties.delete_children (); } | |
3241 | |
3242 base_properties& get_properties (void) { return xproperties; } | |
3243 | |
7222 | 3244 const base_properties& get_properties (void) const { return xproperties; } |
3245 | |
6874 | 3246 bool valid_object (void) const { return true; } |
3247 }; | |
3248 | |
3249 // --------------------------------------------------------------------- | |
3250 | |
7365 | 3251 class OCTINTERP_API surface : public base_graphics_object |
6874 | 3252 { |
3253 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3254 class OCTINTERP_API properties : public base_properties |
6874 | 3255 { |
3256 public: | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3257 octave_value get_color_data (void) const; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3258 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3259 bool is_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3260 { return (climinclude.is_on () && cdatamapping.is ("scaled")); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3261 std::string get_climinclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3262 { return climinclude.current_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3263 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3264 bool is_aliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3265 { return (aliminclude.is_on () && alphadatamapping.is ("scaled")); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3266 std::string get_aliminclude (void) const |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3267 { return aliminclude.current_value (); } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3268 |
6874 | 3269 // See the genprops.awk script for an explanation of the |
3270 // properties declarations. | |
3271 | |
7363 | 3272 BEGIN_PROPERTIES(surface) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3273 array_property xdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3274 array_property ydata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3275 array_property zdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3276 array_property cdata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3277 radio_property cdatamapping al , "{scaled}|direct" |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3278 color_property facecolor , "{flat}|none|interp|texturemap" |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3279 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7379 | 3280 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7363 | 3281 radio_property linestyle , "{-}|--|:|-.|none" |
3282 double_property linewidth , 0.5 | |
3283 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h" | |
3284 color_property markeredgecolor , "{auto}|none" | |
3285 color_property markerfacecolor , "auto|{none}" | |
3286 double_property markersize , 6 | |
3287 string_property keylabel , "" | |
7384 | 3288 radio_property interpreter , "{tex}|none|latex" |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3289 array_property alphadata u , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3290 radio_property alphadatamapping l , "none|direct|{scaled}" |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3291 double_property ambientstrength , 0.3 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3292 radio_property backfacelighting , "unlit|lit|{reverselit}" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3293 double_property diffusestrength , 0.6 |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3294 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3295 radio_property edgelighting , "{none}|flat|gouraud|phong" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3296 radio_property erasemode , "{normal}|none|xor|background" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3297 radio_property facelighting , "{none}|flat|gouraud|phong" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3298 radio_property meshstyle , "{both}|row|column" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3299 radio_property normalmode u , "{auto}|manual" |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3300 double_property specularcolorreflectance , 1 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3301 double_property specularexponent , 10 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3302 double_property specularstrength , 0.9 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3303 array_property vertexnormals u , Matrix () |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3304 // hidden properties for limit computation |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3305 row_vector_property xlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3306 row_vector_property ylim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3307 row_vector_property zlim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3308 row_vector_property clim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3309 row_vector_property alim hlr , Matrix () |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3310 bool_property xliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3311 bool_property yliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3312 bool_property zliminclude hl , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3313 bool_property climinclude hlg , "on" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3314 bool_property aliminclude hlg , "on" |
6874 | 3315 END_PROPERTIES |
3316 | |
7363 | 3317 protected: |
3318 void init (void) | |
3319 { | |
7848
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3320 xdata.add_constraint (dim_vector (-1, -1)); |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3321 ydata.add_constraint (dim_vector (-1, -1)); |
6bb2bbc2bf45
Remove data_property, replace with array_property or row_vector_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7847
diff
changeset
|
3322 zdata.add_constraint (dim_vector (-1, -1)); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3323 alphadata.add_constraint ("double"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3324 alphadata.add_constraint ("uint8"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3325 alphadata.add_constraint (dim_vector (-1, -1)); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3326 vertexnormals.add_constraint (dim_vector (-1, -1, 3)); |
7836
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3327 cdata.add_constraint ("double"); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3328 cdata.add_constraint ("uint8"); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3329 cdata.add_constraint (dim_vector (-1, -1)); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
3330 cdata.add_constraint (dim_vector (-1, -1, 3)); |
7363 | 3331 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3332 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3333 private: |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3334 void update_normals (void); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3335 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3336 void update_xdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3337 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3338 update_normals (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3339 set_xlim (xdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3340 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3341 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3342 void update_ydata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3343 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3344 update_normals (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3345 set_ylim (ydata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3346 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3347 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3348 void update_zdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3349 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3350 update_normals (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3351 set_zlim (zdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3352 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3353 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3354 void update_cdata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3355 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3356 if (cdatamapping_is ("scaled")) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3357 set_clim (cdata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3358 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3359 clim = cdata.get_limits (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3360 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3361 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3362 void update_alphadata (void) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3363 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3364 if (alphadatamapping_is ("scaled")) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3365 set_alim (alphadata.get_limits ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3366 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3367 alim = alphadata.get_limits (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3368 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3369 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3370 void update_normalmode (void) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3371 { update_normals (); } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3372 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3373 void update_vertexnormals (void) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3374 { set_normalmode ("manual"); } |
6874 | 3375 }; |
3376 | |
3377 private: | |
3378 properties xproperties; | |
3379 | |
3380 public: | |
3381 surface (const graphics_handle& mh, const graphics_handle& p) | |
3382 : base_graphics_object (), xproperties (mh, p) | |
3383 { | |
3384 xproperties.override_defaults (*this); | |
3385 } | |
3386 | |
3387 ~surface (void) { xproperties.delete_children (); } | |
3388 | |
3389 base_properties& get_properties (void) { return xproperties; } | |
3390 | |
7222 | 3391 const base_properties& get_properties (void) const { return xproperties; } |
3392 | |
6874 | 3393 bool valid_object (void) const { return true; } |
3394 }; | |
3395 | |
3396 octave_value | |
3397 get_property_from_handle (double handle, const std::string &property, | |
3398 const std::string &func); | |
3399 bool | |
3400 set_property_in_handle (double handle, const std::string &property, | |
3401 const octave_value &arg, const std::string &func); | |
3402 | |
3403 // --------------------------------------------------------------------- | |
3404 | |
7365 | 3405 class OCTINTERP_API gh_manager |
6874 | 3406 { |
3407 protected: | |
3408 | |
3409 gh_manager (void); | |
3410 | |
3411 public: | |
3412 | |
3413 static bool instance_ok (void) | |
3414 { | |
3415 bool retval = true; | |
3416 | |
3417 if (! instance) | |
3418 instance = new gh_manager (); | |
3419 | |
3420 if (! instance) | |
3421 { | |
3422 ::error ("unable to create gh_manager!"); | |
3423 | |
3424 retval = false; | |
3425 } | |
3426 | |
3427 return retval; | |
3428 } | |
3429 | |
3430 static void free (const graphics_handle& h) | |
3431 { | |
3432 if (instance_ok ()) | |
3433 instance->do_free (h); | |
3434 } | |
3435 | |
3436 static graphics_handle lookup (double val) | |
3437 { | |
3438 return instance_ok () ? instance->do_lookup (val) : graphics_handle (); | |
3439 } | |
3440 | |
3441 static graphics_object get_object (const graphics_handle& h) | |
3442 { | |
3443 return instance_ok () ? instance->do_get_object (h) : graphics_object (); | |
3444 } | |
3445 | |
3446 static graphics_handle | |
3447 make_graphics_handle (const std::string& go_name, | |
7370 | 3448 const graphics_handle& parent, bool do_createfcn = true) |
6874 | 3449 { |
3450 return instance_ok () | |
7370 | 3451 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn) |
6874 | 3452 : graphics_handle (); |
3453 } | |
3454 | |
3455 static graphics_handle make_figure_handle (double val) | |
3456 { | |
3457 return instance_ok () | |
3458 ? instance->do_make_figure_handle (val) : graphics_handle (); | |
3459 } | |
3460 | |
3461 static void push_figure (const graphics_handle& h) | |
3462 { | |
3463 if (instance_ok ()) | |
3464 instance->do_push_figure (h); | |
3465 } | |
3466 | |
3467 static void pop_figure (const graphics_handle& h) | |
3468 { | |
3469 if (instance_ok ()) | |
3470 instance->do_pop_figure (h); | |
3471 } | |
3472 | |
3473 static graphics_handle current_figure (void) | |
3474 { | |
3475 return instance_ok () | |
3476 ? instance->do_current_figure () : graphics_handle (); | |
3477 } | |
3478 | |
3479 static Matrix handle_list (void) | |
3480 { | |
3481 return instance_ok () ? instance->do_handle_list () : Matrix (); | |
3482 } | |
3483 | |
3484 static Matrix figure_handle_list (void) | |
3485 { | |
3486 return instance_ok () ? instance->do_figure_handle_list () : Matrix (); | |
3487 } | |
3488 | |
3489 private: | |
3490 | |
3491 static gh_manager *instance; | |
3492 | |
3493 typedef std::map<graphics_handle, graphics_object>::iterator iterator; | |
3494 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator; | |
3495 | |
3496 typedef std::set<graphics_handle>::iterator free_list_iterator; | |
3497 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator; | |
3498 | |
3499 typedef std::list<graphics_handle>::iterator figure_list_iterator; | |
3500 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator; | |
3501 | |
3502 // A map of handles to graphics objects. | |
3503 std::map<graphics_handle, graphics_object> handle_map; | |
3504 | |
3505 // The available graphics handles. | |
3506 std::set<graphics_handle> handle_free_list; | |
3507 | |
3508 // The next handle available if handle_free_list is empty. | |
7286 | 3509 double next_handle; |
6874 | 3510 |
3511 // The allocated figure handles. Top of the stack is most recently | |
3512 // created. | |
3513 std::list<graphics_handle> figure_list; | |
3514 | |
3515 graphics_handle get_handle (const std::string& go_name); | |
3516 | |
3517 void do_free (const graphics_handle& h); | |
3518 | |
3519 graphics_handle do_lookup (double val) | |
3520 { | |
7363 | 3521 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val)); |
6874 | 3522 |
3523 return (p != handle_map.end ()) ? p->first : graphics_handle (); | |
3524 } | |
3525 | |
3526 graphics_object do_get_object (const graphics_handle& h) | |
3527 { | |
7379 | 3528 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); |
6874 | 3529 |
3530 return (p != handle_map.end ()) ? p->second : graphics_object (); | |
3531 } | |
3532 | |
3533 graphics_handle do_make_graphics_handle (const std::string& go_name, | |
7370 | 3534 const graphics_handle& p, bool do_createfcn); |
6874 | 3535 |
3536 graphics_handle do_make_figure_handle (double val); | |
3537 | |
3538 Matrix do_handle_list (void) | |
3539 { | |
3540 Matrix retval (1, handle_map.size ()); | |
3541 octave_idx_type i = 0; | |
3542 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) | |
7056 | 3543 { |
3544 graphics_handle h = p->first; | |
3545 retval(i++) = h.value (); | |
3546 } | |
6874 | 3547 return retval; |
3548 } | |
3549 | |
3550 Matrix do_figure_handle_list (void) | |
3551 { | |
3552 Matrix retval (1, figure_list.size ()); | |
3553 octave_idx_type i = 0; | |
3554 for (const_figure_list_iterator p = figure_list.begin (); | |
3555 p != figure_list.end (); | |
3556 p++) | |
7056 | 3557 { |
3558 graphics_handle h = *p; | |
3559 retval(i++) = h.value (); | |
3560 } | |
6874 | 3561 return retval; |
3562 } | |
3563 | |
3564 void do_push_figure (const graphics_handle& h); | |
3565 | |
3566 void do_pop_figure (const graphics_handle& h); | |
3567 | |
3568 graphics_handle do_current_figure (void) const | |
3569 { | |
3570 return figure_list.empty () ? graphics_handle () : figure_list.front (); | |
3571 } | |
3572 }; | |
3573 | |
3574 | |
3575 // This function is NOT equivalent to the scripting language function gcf. | |
7365 | 3576 OCTINTERP_API graphics_handle gcf (void); |
6874 | 3577 |
3578 // This function is NOT equivalent to the scripting language function gca. | |
7365 | 3579 OCTINTERP_API graphics_handle gca (void); |
6874 | 3580 |
3581 #endif | |
3582 | |
3583 /* | |
3584 ;;; Local Variables: *** | |
3585 ;;; mode: C++ *** | |
3586 ;;; End: *** | |
3587 */ |