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