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