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