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