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