Mercurial > octave-nkf
annotate src/graphics.h.in @ 10722:755fcb5baad3
Add the reset built function
author | David Bateman <dbateman@free.fr> |
---|---|
date | Wed, 23 Jun 2010 11:23:32 +0200 |
parents | 9d4a198614ab |
children | f0236b444356 |
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 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2226 virtual void reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2227 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2228 if (valid_object ()) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2229 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2230 std::string msg = (type () + "::reset_default_properties"); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2231 gripe_not_implemented (msg.c_str ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2232 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2233 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2234 error ("base_graphics_object::default: invalid graphics object"); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2235 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2236 |
6874 | 2237 protected: |
2238 // A reference count. | |
2239 int count; | |
2240 }; | |
2241 | |
7365 | 2242 class OCTINTERP_API graphics_object |
6874 | 2243 { |
2244 public: | |
2245 graphics_object (void) : rep (new base_graphics_object ()) { } | |
2246 | |
2247 graphics_object (base_graphics_object *new_rep) | |
2248 : rep (new_rep) { } | |
2249 | |
2250 graphics_object (const graphics_object& obj) | |
2251 { | |
2252 rep = obj.rep; | |
2253 rep->count++; | |
2254 } | |
2255 | |
2256 graphics_object& operator = (const graphics_object& obj) | |
2257 { | |
2258 if (rep != obj.rep) | |
2259 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2260 if (--rep->count == 0) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2261 delete rep; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2262 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2263 rep = obj.rep; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2264 rep->count++; |
6874 | 2265 } |
2266 | |
2267 return *this; | |
2268 } | |
2269 | |
2270 ~graphics_object (void) | |
2271 { | |
2272 if (--rep->count == 0) | |
2273 delete rep; | |
2274 } | |
2275 | |
2276 void mark_modified (void) { rep->mark_modified (); } | |
2277 | |
2278 void override_defaults (base_graphics_object& obj) | |
2279 { | |
2280 rep->override_defaults (obj); | |
2281 } | |
2282 | |
7214 | 2283 void set_from_list (property_list& plist) { rep->set_from_list (plist); } |
6874 | 2284 |
7189 | 2285 void set (const caseless_str& name, const octave_value& val) |
6874 | 2286 { |
2287 rep->set (name, val); | |
2288 } | |
2289 | |
2290 void set (const octave_value_list& args); | |
2291 | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2292 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
|
2293 octave_idx_type row); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2294 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2295 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
|
2296 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2297 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
|
2298 const octave_value& val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2299 |
7214 | 2300 void set_defaults (const std::string& mode) { rep->set_defaults (mode); } |
2301 | |
7379 | 2302 octave_value get (bool all = false) const { return rep->get (all); } |
6874 | 2303 |
7189 | 2304 octave_value get (const caseless_str& name) const |
6874 | 2305 { |
2306 return name.compare ("default") | |
2307 ? get_defaults () | |
2308 : (name.compare ("factory") | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2309 ? get_factory_defaults () : rep->get (name)); |
6874 | 2310 } |
2311 | |
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
|
2312 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
|
2313 { |
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
|
2314 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
|
2315 } |
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
|
2316 |
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
|
2317 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
|
2318 { |
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
|
2319 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
|
2320 } |
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
|
2321 |
7189 | 2322 octave_value get_default (const caseless_str& name) const |
6874 | 2323 { |
2324 return rep->get_default (name); | |
2325 } | |
2326 | |
7189 | 2327 octave_value get_factory_default (const caseless_str& name) const |
6874 | 2328 { |
2329 return rep->get_factory_default (name); | |
2330 } | |
2331 | |
2332 octave_value get_defaults (void) const { return rep->get_defaults (); } | |
2333 | |
2334 octave_value get_factory_defaults (void) const | |
2335 { | |
2336 return rep->get_factory_defaults (); | |
2337 } | |
2338 | |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10596
diff
changeset
|
2339 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
|
2340 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10596
diff
changeset
|
2341 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
|
2342 |
6874 | 2343 graphics_handle get_parent (void) const { return rep->get_parent (); } |
2344 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
2345 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
|
2346 |
7214 | 2347 void remove_child (const graphics_handle& h) { rep->remove_child (h); } |
2348 | |
2349 void adopt (const graphics_handle& h) { rep->adopt (h); } | |
2350 | |
2351 void reparent (const graphics_handle& h) { rep->reparent (h); } | |
6874 | 2352 |
2353 void defaults (void) const { rep->defaults (); } | |
2354 | |
2355 bool isa (const std::string& go_name) const { return rep->isa (go_name); } | |
2356 | |
2357 base_properties& get_properties (void) { return rep->get_properties (); } | |
2358 | |
7222 | 2359 const base_properties& get_properties (void) const |
2360 { | |
2361 return rep->get_properties (); | |
2362 } | |
2363 | |
7214 | 2364 void update_axis_limits (const std::string& axis_type) |
2365 { | |
2366 rep->update_axis_limits (axis_type); | |
2367 } | |
2368 | |
6874 | 2369 bool valid_object (void) const { return rep->valid_object (); } |
2370 | |
8208 | 2371 std::string type (void) const { return rep->type (); } |
2372 | |
6874 | 2373 operator bool (void) const { return rep->valid_object (); } |
2374 | |
7222 | 2375 // FIXME -- these functions should be generated automatically by the |
2376 // genprops.awk script. | |
2377 // | |
2378 // 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
|
2379 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2380 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
|
2381 { 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
|
2382 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2383 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
|
2384 { 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
|
2385 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2386 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
|
2387 { 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
|
2388 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2389 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
|
2390 { 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
|
2391 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2392 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
|
2393 { 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
|
2394 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2395 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
|
2396 { 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
|
2397 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2398 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
|
2399 { 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
|
2400 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2401 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
|
2402 { 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
|
2403 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2404 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
|
2405 { 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
|
2406 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2407 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
|
2408 { return get_properties ().is_aliminclude (); } |
8249 | 2409 |
2410 bool is_handle_visible (void) const | |
2411 { 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
|
2412 |
7419 | 2413 graphics_backend get_backend (void) const { return rep->get_backend (); } |
7408 | 2414 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2415 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
|
2416 listener_mode mode = POSTSET) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2417 { 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
|
2418 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2419 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
|
2420 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
|
2421 { 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
|
2422 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2423 void reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2424 { rep->reset_default_properties (); } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2425 |
7408 | 2426 private: |
7419 | 2427 base_graphics_object *rep; |
7408 | 2428 }; |
2429 | |
2430 // --------------------------------------------------------------------- | |
2431 | |
7365 | 2432 class OCTINTERP_API root_figure : public base_graphics_object |
6874 | 2433 { |
2434 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
2435 class OCTINTERP_API properties : public base_properties |
6874 | 2436 { |
2437 public: | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2438 void remove_child (const graphics_handle& h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2439 |
6874 | 2440 // See the genprops.awk script for an explanation of the |
2441 // properties declarations. | |
2442 | |
9778 | 2443 // FIXME -- it seems strange to me that the diary, diaryfile, |
2444 // echo, format, formatspacing, language, and recursionlimit | |
2445 // properties are here. WTF do they have to do with graphics? | |
2446 // Also note that these properties (and the monitorpositions, | |
2447 // pointerlocation, and pointerwindow properties) are not yet used | |
2448 // by Octave, so setting them will have no effect, and changes | |
2449 // made elswhere (say, the diary or format functions) will not | |
2450 // cause these properties to be updated. | |
2451 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
2452 BEGIN_PROPERTIES (root_figure, root) |
9778 | 2453 handle_property callbackobject Sr , graphics_handle () |
2454 array_property commandwindowsize r , Matrix (1, 2, 0) | |
7363 | 2455 handle_property currentfigure S , graphics_handle () |
9778 | 2456 bool_property diary , "off" |
2457 string_property diaryfile , "diary" | |
2458 bool_property echo , "off" | |
2459 radio_property format , "+|bank|bit|debug|hex|long|longe|longeng|longg|native-bit|native-hex|rational|{short}|shorte|shorteng|shortg" | |
2460 radio_property formatspacing , "{loose}|compact" | |
2461 string_property language , "ascii" | |
9779
2941c1daf509
fix typo in previous change
John W. Eaton <jwe@octave.org>
parents:
9778
diff
changeset
|
2462 array_property monitorpositions , Matrix (1, 4, 0) |
9778 | 2463 array_property pointerlocation , Matrix (1, 2, 0) |
2464 double_property pointerwindow , 0.0 | |
2465 double_property recursionlimit , 256.0 | |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8465
diff
changeset
|
2466 double_property screendepth r , default_screendepth () |
9778 | 2467 double_property screenpixelsperinch r , default_screenpixelsperinch () |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8465
diff
changeset
|
2468 array_property screensize r , default_screensize () |
9778 | 2469 bool_property showhiddenhandles , "off" |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8465
diff
changeset
|
2470 radio_property units U , "inches|centimeters|normalized|points|{pixels}" |
6874 | 2471 END_PROPERTIES |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2472 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2473 private: |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7821
diff
changeset
|
2474 std::list<graphics_handle> cbo_stack; |
6874 | 2475 }; |
2476 | |
2477 private: | |
2478 properties xproperties; | |
2479 | |
2480 public: | |
2481 | |
7363 | 2482 root_figure (void) : xproperties (0, graphics_handle ()), default_properties () { } |
6874 | 2483 |
2484 ~root_figure (void) { xproperties.delete_children (); } | |
2485 | |
2486 void mark_modified (void) { } | |
2487 | |
2488 void override_defaults (base_graphics_object& obj) | |
2489 { | |
2490 // Now override with our defaults. If the default_properties | |
2491 // list includes the properties for all defaults (line, | |
2492 // surface, etc.) then we don't have to know the type of OBJ | |
2493 // here, we just call its set function and let it decide which | |
2494 // properties from the list to use. | |
2495 obj.set_from_list (default_properties); | |
2496 } | |
2497 | |
7189 | 2498 void set (const caseless_str& name, const octave_value& value) |
6874 | 2499 { |
2500 if (name.compare ("default", 7)) | |
2501 // strip "default", pass rest to function that will | |
2502 // parse the remainder and add the element to the | |
2503 // default_properties map. | |
2504 default_properties.set (name.substr (7), value); | |
2505 else | |
2506 xproperties.set (name, value); | |
2507 } | |
2508 | |
7189 | 2509 octave_value get (const caseless_str& name) const |
6874 | 2510 { |
2511 octave_value retval; | |
2512 | |
2513 if (name.compare ("default", 7)) | |
2514 return get_default (name.substr (7)); | |
2515 else if (name.compare ("factory", 7)) | |
2516 return get_factory_default (name.substr (7)); | |
2517 else | |
2518 retval = xproperties.get (name); | |
2519 | |
2520 return retval; | |
2521 } | |
2522 | |
7189 | 2523 octave_value get_default (const caseless_str& name) const |
6874 | 2524 { |
2525 octave_value retval = default_properties.lookup (name); | |
2526 | |
2527 if (retval.is_undefined ()) | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2528 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2529 // no default property found, use factory default |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2530 retval = factory_properties.lookup (name); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2531 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2532 if (retval.is_undefined ()) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2533 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
|
2534 } |
6874 | 2535 |
2536 return retval; | |
2537 } | |
2538 | |
7189 | 2539 octave_value get_factory_default (const caseless_str& name) const |
6874 | 2540 { |
2541 octave_value retval = factory_properties.lookup (name); | |
2542 | |
2543 if (retval.is_undefined ()) | |
2544 error ("get: invalid factory default property `%s'", name.c_str ()); | |
2545 | |
2546 return retval; | |
2547 } | |
2548 | |
2549 octave_value get_defaults (void) const | |
2550 { | |
2551 return default_properties.as_struct ("default"); | |
2552 } | |
2553 | |
2554 octave_value get_factory_defaults (void) const | |
2555 { | |
2556 return factory_properties.as_struct ("factory"); | |
2557 } | |
2558 | |
2559 base_properties& get_properties (void) { return xproperties; } | |
2560 | |
7222 | 2561 const base_properties& get_properties (void) const { return xproperties; } |
2562 | |
6874 | 2563 bool valid_object (void) const { return true; } |
2564 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2565 void reset_default_properties (void); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2566 |
6874 | 2567 private: |
2568 property_list default_properties; | |
2569 | |
2570 static property_list factory_properties; | |
2571 | |
2572 static property_list::plist_map_type init_factory_properties (void); | |
2573 }; | |
2574 | |
2575 // --------------------------------------------------------------------- | |
2576 | |
7365 | 2577 class OCTINTERP_API figure : public base_graphics_object |
6874 | 2578 { |
2579 public: | |
7445 | 2580 class OCTINTERP_API properties : public base_properties |
6874 | 2581 { |
2582 public: | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8263
diff
changeset
|
2583 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
|
2584 |
7366 | 2585 void set_visible (const octave_value& val); |
6874 | 2586 |
7408 | 2587 graphics_backend get_backend (void) const |
2588 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2589 if (! backend) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2590 backend = graphics_backend::default_backend (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2591 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2592 return backend; |
7408 | 2593 } |
2594 | |
7439 | 2595 void set_backend (const graphics_backend& b) |
2596 { | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2597 if (backend) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2598 backend.object_destroyed (__myhandle__); |
7439 | 2599 backend = b; |
2600 __backend__ = b.get_name (); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7846
diff
changeset
|
2601 __plot_stream__ = Matrix (); |
7439 | 2602 mark_modified (); |
2603 } | |
2604 | |
2605 void set___backend__ (const octave_value& val) | |
2606 { | |
2607 if (! error_state) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2608 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2609 if (val.is_string ()) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2610 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2611 std::string nm = val.string_value (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2612 graphics_backend b = graphics_backend::find_backend (nm); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2613 if (b.get_name () != nm) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2614 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2615 error ("set___backend__: invalid backend"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2616 } |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2617 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2618 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2619 set_backend (b); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2620 mark_modified (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2621 } |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2622 } |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2623 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2624 error ("set___backend__ must be a string"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2625 } |
7439 | 2626 } |
7408 | 2627 |
7447 | 2628 Matrix get_boundingbox (bool internal = false) const; |
7445 | 2629 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2630 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
|
2631 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2632 std::string get_title (void) const; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2633 |
6874 | 2634 // See the genprops.awk script for an explanation of the |
2635 // properties declarations. | |
2636 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
2637 BEGIN_PROPERTIES (figure) |
7379 | 2638 any_property __plot_stream__ h , Matrix () |
2639 bool_property __enhanced__ h , "on" | |
10505
82ee24bf783c
graphics.h.in: Fix nextplot property values.
Ben Abbott <bpabbott@mac.com>
parents:
10402
diff
changeset
|
2640 radio_property nextplot , "new|{add}|replacechildren|replace" |
7363 | 2641 callback_property closerequestfcn , "closereq" |
2642 handle_property currentaxes S , graphics_handle () | |
2643 array_property colormap , jet_colormap () | |
7405 | 2644 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
|
2645 color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) |
7405 | 2646 array_property alphamap , Matrix (64, 1, 1) |
2647 string_property currentcharacter r , "" | |
2648 handle_property currentobject r , graphics_handle () | |
10517 | 2649 array_property currentpoint r , Matrix (2, 1, 0) |
7405 | 2650 bool_property dockcontrols , "off" |
2651 bool_property doublebuffer , "on" | |
2652 string_property filename r , "" | |
2653 bool_property integerhandle , "on" | |
2654 bool_property inverthardcopy , "off" | |
2655 callback_property keypressfcn , Matrix () | |
2656 callback_property keyreleasefcn , Matrix () | |
2657 radio_property menubar , "none|{figure}" | |
2658 double_property mincolormap , 64 | |
2659 string_property name , "" | |
2660 bool_property numbertitle , "on" | |
2661 radio_property paperunits , "{inches}|centimeters|normalized|points" | |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
2662 array_property paperposition , default_figure_paperposition () |
7405 | 2663 radio_property paperpositionmode , "auto|{manual}" |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
2664 array_property papersize , default_figure_papersize () |
8355
a8019b9644ca
graphics.h.in: Add props screensize & screenpixelsperinch.
Ben Abbott <bpabbott@mac.com>
parents:
8333
diff
changeset
|
2665 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 | 2666 radio_property pointer , "crosshair|fullcrosshair|{arrow}|ibeam|watch|topl|topr|botl|botr|left|top|right|bottom|circle|cross|fleur|custom|hand" |
2667 array_property pointershapecdata , Matrix (16, 16, 0) | |
2668 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
|
2669 array_property position S , default_figure_position () |
7405 | 2670 radio_property renderer , "{painters}|zbuffer|opengl|none" |
2671 radio_property renderermode , "{auto}|manual" | |
2672 bool_property resize , "on" | |
2673 callback_property resizefcn , Matrix () | |
2674 radio_property selectiontype , "{normal}|open|alt|extend" | |
2675 radio_property toolbar , "none|{auto}|figure" | |
2676 radio_property units , "inches|centimeters|normalized|points|{pixels}|characters" | |
2677 callback_property windowbuttondownfcn , Matrix () | |
2678 callback_property windowbuttonmotionfcn , Matrix () | |
2679 callback_property windowbuttonupfcn , Matrix () | |
2680 callback_property windowbuttonwheelfcn , Matrix () | |
2681 radio_property windowstyle , "{normal}|modal|docked" | |
2682 string_property wvisual , "" | |
2683 radio_property wvisualmode , "{auto}|manual" | |
2684 string_property xdisplay , "" | |
2685 string_property xvisual , "" | |
2686 radio_property xvisualmode , "{auto}|manual" | |
2687 callback_property buttondownfcn , Matrix () | |
7439 | 2688 string_property __backend__ s , "gnuplot" |
6874 | 2689 END_PROPERTIES |
7363 | 2690 |
2691 protected: | |
2692 void init (void) | |
2693 { | |
2694 colormap.add_constraint (dim_vector (-1, 3)); | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2695 alphamap.add_constraint (dim_vector (-1, 1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2696 paperposition.add_constraint (dim_vector (1, 4)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2697 pointershapecdata.add_constraint (dim_vector (16, 16)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2698 pointershapehotspot.add_constraint (dim_vector (1, 2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2699 position.add_constraint (dim_vector (1, 4)); |
7363 | 2700 } |
7408 | 2701 |
2702 private: | |
2703 mutable graphics_backend backend; | |
6874 | 2704 }; |
2705 | |
2706 private: | |
2707 properties xproperties; | |
2708 | |
2709 public: | |
2710 figure (const graphics_handle& mh, const graphics_handle& p) | |
2711 : base_graphics_object (), xproperties (mh, p), default_properties () | |
2712 { | |
2713 xproperties.override_defaults (*this); | |
2714 } | |
2715 | |
2716 ~figure (void) | |
2717 { | |
7386 | 2718 xproperties.delete_children (); |
6874 | 2719 } |
2720 | |
2721 void override_defaults (base_graphics_object& obj) | |
2722 { | |
2723 // Allow parent (root figure) to override first (properties knows how | |
2724 // to find the parent object). | |
2725 xproperties.override_defaults (obj); | |
2726 | |
2727 // Now override with our defaults. If the default_properties | |
2728 // list includes the properties for all defaults (line, | |
2729 // surface, etc.) then we don't have to know the type of OBJ | |
2730 // here, we just call its set function and let it decide which | |
2731 // properties from the list to use. | |
2732 obj.set_from_list (default_properties); | |
2733 } | |
2734 | |
7189 | 2735 void set (const caseless_str& name, const octave_value& value) |
6874 | 2736 { |
2737 if (name.compare ("default", 7)) | |
2738 // strip "default", pass rest to function that will | |
2739 // parse the remainder and add the element to the | |
2740 // default_properties map. | |
2741 default_properties.set (name.substr (7), value); | |
2742 else | |
2743 xproperties.set (name, value); | |
2744 } | |
2745 | |
7189 | 2746 octave_value get (const caseless_str& name) const |
6874 | 2747 { |
2748 octave_value retval; | |
2749 | |
2750 if (name.compare ("default", 7)) | |
2751 retval = get_default (name.substr (7)); | |
2752 else | |
2753 retval = xproperties.get (name); | |
2754 | |
2755 return retval; | |
2756 } | |
2757 | |
7189 | 2758 octave_value get_default (const caseless_str& name) const; |
6874 | 2759 |
2760 octave_value get_defaults (void) const | |
2761 { | |
2762 return default_properties.as_struct ("default"); | |
2763 } | |
2764 | |
2765 base_properties& get_properties (void) { return xproperties; } | |
2766 | |
7222 | 2767 const base_properties& get_properties (void) const { return xproperties; } |
2768 | |
6874 | 2769 bool valid_object (void) const { return true; } |
2770 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2771 void reset_default_properties (void); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2772 |
6874 | 2773 private: |
2774 property_list default_properties; | |
2775 }; | |
2776 | |
2777 // --------------------------------------------------------------------- | |
2778 | |
7435 | 2779 class OCTINTERP_API graphics_xform |
2780 { | |
2781 public: | |
2782 graphics_xform (void) | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2783 : xform (xform_eye ()), xform_inv (xform_eye ()), zlim (1, 2, 0.0) |
7435 | 2784 { |
2785 sx = sy = sz = "linear"; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2786 zlim(1) = 1.0; |
7435 | 2787 } |
2788 | |
2789 graphics_xform (const Matrix& xm, const Matrix& xim, | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2790 const scaler& x, const scaler& y, const scaler& z, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2791 const Matrix& zl) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2792 : xform (xm), xform_inv (xim), sx (x), sy (y), sz (z), zlim (zl) { } |
7435 | 2793 |
2794 graphics_xform (const graphics_xform& g) | |
2795 : 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
|
2796 sy (g.sy), sz (g.sz), zlim (g.zlim) { } |
7435 | 2797 |
2798 ~graphics_xform (void) { } | |
2799 | |
2800 graphics_xform& operator = (const graphics_xform& g) | |
2801 { | |
2802 xform = g.xform; | |
2803 xform_inv = g.xform_inv; | |
2804 sx = g.sx; | |
2805 sy = g.sy; | |
2806 sz = g.sz; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2807 zlim = g.zlim; |
7435 | 2808 |
2809 return *this; | |
2810 } | |
2811 | |
2812 static ColumnVector xform_vector (double x, double y, double z); | |
2813 | |
2814 static Matrix xform_eye (void); | |
2815 | |
2816 ColumnVector transform (double x, double y, double z, | |
10553 | 2817 bool use_scale = true) const; |
7435 | 2818 |
2819 ColumnVector untransform (double x, double y, double z, | |
10553 | 2820 bool use_scale = true) const; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2821 |
10553 | 2822 ColumnVector untransform (double x, double y, bool use_scale = true) const |
2823 { return untransform (x, y, (zlim(0)+zlim(1))/2, use_scale); } | |
7435 | 2824 |
2825 Matrix xscale (const Matrix& m) const { return sx.scale (m); } | |
2826 Matrix yscale (const Matrix& m) const { return sy.scale (m); } | |
2827 Matrix zscale (const Matrix& m) const { return sz.scale (m); } | |
2828 | |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2829 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
|
2830 { |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2831 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
|
2832 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2833 if (sx.is_linear () && sy.is_linear () |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2834 && (! has_z || sz.is_linear ())) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2835 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
|
2836 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2837 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
|
2838 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2839 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
|
2840 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2841 for (int i = 0; i < r; i++) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2842 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2843 retval(i,0) = sx.scale (m(i,0)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2844 retval(i,1) = sy.scale (m(i,1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2845 if (has_z) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2846 retval(i,2) = sz.scale (m(i,2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2847 } |
7832
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2848 |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2849 return retval; |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2850 } |
e06fdf7ea647
Fix default value of patch::facelighting. Add scaler/graphics_xform utilities
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7830
diff
changeset
|
2851 |
7435 | 2852 private: |
2853 Matrix xform; | |
2854 Matrix xform_inv; | |
2855 scaler sx, sy, sz; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2856 Matrix zlim; |
7435 | 2857 }; |
2858 | |
7365 | 2859 class OCTINTERP_API axes : public base_graphics_object |
6874 | 2860 { |
2861 public: | |
7445 | 2862 class OCTINTERP_API properties : public base_properties |
6874 | 2863 { |
2864 public: | |
2865 void set_defaults (base_graphics_object& obj, const std::string& mode); | |
2866 | |
2867 void remove_child (const graphics_handle& h); | |
2868 | |
7427 | 2869 const scaler& get_x_scaler (void) const { return sx; } |
2870 const scaler& get_y_scaler (void) const { return sy; } | |
2871 const scaler& get_z_scaler (void) const { return sz; } | |
2872 | |
7447 | 2873 Matrix get_boundingbox (bool internal = false) const; |
7427 | 2874 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2875 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
|
2876 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2877 if (units_is ("normalized")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2878 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2879 update_transform (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2880 base_properties::update_boundingbox (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2881 } |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2882 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2883 |
7427 | 2884 void update_camera (void); |
2885 void update_aspectratios (void); | |
2886 void update_transform (void) | |
2887 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2888 update_aspectratios (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
2889 update_camera (); |
7427 | 2890 } |
2891 | |
7435 | 2892 graphics_xform get_transform (void) const |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
2893 { return graphics_xform (x_render, x_render_inv, sx, sy, sz, x_zlim); } |
7435 | 2894 |
2895 Matrix get_transform_matrix (void) const { return x_render; } | |
2896 Matrix get_inverse_transform_matrix (void) const { return x_render_inv; } | |
2897 Matrix get_opengl_matrix_1 (void) const { return x_gl_mat1; } | |
2898 Matrix get_opengl_matrix_2 (void) const { return x_gl_mat2; } | |
2899 Matrix get_transform_zlim (void) const { return x_zlim; } | |
2900 | |
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
|
2901 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
|
2902 { 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
|
2903 |
1357bcae6e29
added pixel<->coord transform in axes and use it for display of cursor
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
2904 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
|
2905 { 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
|
2906 |
9455 | 2907 void zoom_about_point (double x, double y, double factor, |
2908 bool push_to_zoom_stack = true); | |
2909 void zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack = true); | |
2910 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
|
2911 void unzoom (void); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2912 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
|
2913 |
7427 | 2914 private: |
2915 scaler sx, sy, sz; | |
2916 Matrix x_render, x_render_inv; | |
2917 Matrix x_gl_mat1, x_gl_mat2; | |
2918 Matrix x_zlim; | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
2919 std::list<octave_value> zoom_stack; |
7427 | 2920 |
8249 | 2921 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
|
2922 const octave_value& v); |
8249 | 2923 |
8208 | 2924 void delete_text_child (handle_property& h); |
2925 | |
6874 | 2926 // See the genprops.awk script for an explanation of the |
2927 // properties declarations. | |
2928 | |
8222
11badf6c9e9f
__go_draw_axes__.m: Support axes interpreter poperty for tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
8210
diff
changeset
|
2929 // 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
|
2930 |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
2931 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
|
2932 array_property position u , default_axes_position () |
7363 | 2933 bool_property box , "on" |
2934 bool_property key , "off" | |
2935 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
|
2936 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
|
2937 any_property keypos , 1 |
7363 | 2938 array_property colororder , default_colororder () |
2939 array_property dataaspectratio m , Matrix (1, 3, 1.0) | |
2940 radio_property dataaspectratiomode , "{auto}|manual" | |
7379 | 2941 radio_property layer , "{bottom}|top" |
7523
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2942 row_vector_property xlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2943 row_vector_property ylim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2944 row_vector_property zlim mu , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2945 row_vector_property clim m , default_lim () |
f2000f1971ab
new row_vector_property class
John W. Eaton <jwe@octave.org>
parents:
7471
diff
changeset
|
2946 row_vector_property alim m , default_lim () |
7363 | 2947 radio_property xlimmode al , "{auto}|manual" |
2948 radio_property ylimmode al , "{auto}|manual" | |
2949 radio_property zlimmode al , "{auto}|manual" | |
2950 radio_property climmode al , "{auto}|manual" | |
7403 | 2951 radio_property alimmode , "{auto}|manual" |
8249 | 2952 handle_property xlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false) |
2953 handle_property ylabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false) | |
2954 handle_property zlabel SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false) | |
2955 handle_property title SOf , gh_manager::make_graphics_handle ("text", __myhandle__, false) | |
7363 | 2956 bool_property xgrid , "off" |
2957 bool_property ygrid , "off" | |
2958 bool_property zgrid , "off" | |
2959 bool_property xminorgrid , "off" | |
2960 bool_property yminorgrid , "off" | |
2961 bool_property zminorgrid , "off" | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2962 row_vector_property xtick mu , default_axes_tick () |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2963 row_vector_property ytick mu , default_axes_tick () |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2964 row_vector_property ztick mu , default_axes_tick () |
7363 | 2965 radio_property xtickmode , "{auto}|manual" |
2966 radio_property ytickmode , "{auto}|manual" | |
2967 radio_property ztickmode , "{auto}|manual" | |
7403 | 2968 bool_property xminortick , "off" |
2969 bool_property yminortick , "off" | |
2970 bool_property zminortick , "off" | |
8333 | 2971 // FIXME -- should be kind of string array. |
7363 | 2972 any_property xticklabel m , "" |
2973 any_property yticklabel m , "" | |
2974 any_property zticklabel m , "" | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2975 radio_property xticklabelmode u , "{auto}|manual" |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2976 radio_property yticklabelmode u , "{auto}|manual" |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
2977 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
|
2978 radio_property interpreter , "tex|{none}|latex" |
7379 | 2979 color_property color , color_property (color_values (1, 1, 1), radio_values ("none")) |
7363 | 2980 color_property xcolor , color_values (0, 0, 0) |
2981 color_property ycolor , color_values (0, 0, 0) | |
2982 color_property zcolor , color_values (0, 0, 0) | |
7427 | 2983 radio_property xscale alu , "{linear}|log" |
2984 radio_property yscale alu , "{linear}|log" | |
2985 radio_property zscale alu , "{linear}|log" | |
2986 radio_property xdir u , "{normal}|reverse" | |
2987 radio_property ydir u , "{normal}|reverse" | |
2988 radio_property zdir u , "{normal}|reverse" | |
7365 | 2989 radio_property yaxislocation , "{left}|right|zero" |
2990 radio_property xaxislocation , "{bottom}|top|zero" | |
7427 | 2991 array_property view u , Matrix () |
10505
82ee24bf783c
graphics.h.in: Fix nextplot property values.
Ben Abbott <bpabbott@mac.com>
parents:
10402
diff
changeset
|
2992 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
|
2993 array_property outerposition u , default_axes_outerposition () |
7379 | 2994 radio_property activepositionproperty , "{outerposition}|position" |
7403 | 2995 color_property ambientlightcolor , color_values (1, 1, 1) |
2996 array_property cameraposition m , Matrix (1, 3, 0.0) | |
2997 array_property cameratarget m , Matrix (1, 3, 0.0) | |
2998 array_property cameraupvector m , Matrix () | |
2999 double_property cameraviewangle m , 10.0 | |
3000 radio_property camerapositionmode , "{auto}|manual" | |
3001 radio_property cameratargetmode , "{auto}|manual" | |
3002 radio_property cameraupvectormode , "{auto}|manual" | |
3003 radio_property cameraviewanglemode , "{auto}|manual" | |
3004 array_property currentpoint , Matrix (2, 3, 0.0) | |
3005 radio_property drawmode , "{normal}|fast" | |
3006 radio_property fontangle , "{normal}|italic|oblique" | |
8944
cb0e9facc342
make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
3007 string_property fontname , OCTAVE_DEFAULT_FONTNAME |
7403 | 3008 double_property fontsize , 12 |
3009 radio_property fontunits , "{points}|normalized|inches|centimeters|pixels" | |
3010 radio_property fontweight , "{normal}|light|demi|bold" | |
7445 | 3011 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
|
3012 string_array_property linestyleorder , "-" |
7403 | 3013 double_property linewidth , 0.5 |
7445 | 3014 radio_property minorgridlinestyle , "-|--|{:}|-.|none" |
7403 | 3015 array_property plotboxaspectratio m , Matrix (1, 3, 1.0) |
3016 radio_property plotboxaspectratiomode , "{auto}|manual" | |
3017 radio_property projection , "{orthographic}|perpective" | |
3018 radio_property tickdir m , "{in}|out" | |
3019 radio_property tickdirmode , "{auto}|manual" | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8599
diff
changeset
|
3020 array_property ticklength , default_axes_ticklength () |
7403 | 3021 array_property tightinset r , Matrix (1, 4, 0.0) |
8333 | 3022 // FIXME -- uicontextmenu should be moved here. |
7403 | 3023 radio_property units , "{normalized}|inches|centimeters|points|pixels|characters" |
3024 // hidden properties for transformation computation | |
3025 array_property x_viewtransform h , Matrix (4, 4, 0.0) | |
3026 array_property x_projectiontransform h , Matrix (4, 4, 0.0) | |
3027 array_property x_viewporttransform h , Matrix (4, 4, 0.0) | |
3028 array_property x_normrendertransform h , Matrix (4, 4, 0.0) | |
3029 array_property x_rendertransform h , Matrix (4, 4, 0.0) | |
7189 | 3030 END_PROPERTIES |
6874 | 3031 |
7363 | 3032 protected: |
8249 | 3033 void init (void); |
7427 | 3034 |
3035 private: | |
3036 void update_xscale (void) { sx = get_xscale (); } | |
3037 void update_yscale (void) { sy = get_yscale (); } | |
3038 void update_zscale (void) { sz = get_zscale (); } | |
3039 | |
3040 void update_view (void) { update_camera (); } | |
3041 | |
3042 void update_xdir (void) { update_camera (); } | |
3043 void update_ydir (void) { update_camera (); } | |
3044 void update_zdir (void) { update_camera (); } | |
7446 | 3045 |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3046 void update_xtick (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3047 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3048 if (xticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3049 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3050 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3051 void update_ytick (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3052 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3053 if (yticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3054 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3055 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3056 void update_ztick (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3057 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3058 if (zticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3059 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3060 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3061 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3062 void update_xticklabelmode (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3063 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3064 if (xticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3065 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3066 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3067 void update_yticklabelmode (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3068 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3069 if (yticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3070 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3071 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3072 void update_zticklabelmode (void) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3073 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3074 if (zticklabelmode.is ("auto")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3075 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3076 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9188
diff
changeset
|
3077 |
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
|
3078 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
|
3079 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
|
3080 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
|
3081 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7826
diff
changeset
|
3082 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
|
3083 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
|
3084 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
|
3085 void fix_limits (array_property& lims) |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3086 { |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3087 if (lims.get ().is_empty ()) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3088 return; |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3089 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3090 Matrix l = lims.get ().matrix_value (); |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3091 if (l(0) > l(1)) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3092 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3093 l(0) = 0; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3094 l(1) = 1; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3095 lims = l; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3096 } |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3097 else if (l(0) == l(1)) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3098 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3099 l(0) -= 0.5; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3100 l(1) += 0.5; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3101 lims = l; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3102 } |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3103 } |
7446 | 3104 |
3105 public: | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7826
diff
changeset
|
3106 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
|
3107 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3108 void update_xlim (bool do_clr_zoom = true) |
7446 | 3109 { |
3110 if (xtickmode.is ("auto")) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3111 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
|
3112 if (xticklabelmode.is ("auto")) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3113 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
|
3114 |
7854
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3115 fix_limits (xlim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3116 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3117 if (do_clr_zoom) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3118 zoom_stack.clear (); |
7446 | 3119 } |
3120 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3121 void update_ylim (bool do_clr_zoom = true) |
7446 | 3122 { |
3123 if (ytickmode.is ("auto")) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3124 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
|
3125 if (yticklabelmode.is ("auto")) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3126 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
|
3127 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3128 fix_limits (ylim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3129 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3130 if (do_clr_zoom) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3131 zoom_stack.clear (); |
7446 | 3132 } |
3133 | |
3134 void update_zlim (void) | |
3135 { | |
3136 if (ztickmode.is ("auto")) | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3137 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
|
3138 if (zticklabelmode.is ("auto")) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3139 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
|
3140 |
228858e69bd1
added {x,y,z}lim sanity check
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7850
diff
changeset
|
3141 fix_limits (zlim); |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3142 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7854
diff
changeset
|
3143 zoom_stack.clear (); |
7446 | 3144 } |
3145 | |
6874 | 3146 }; |
3147 | |
3148 private: | |
3149 properties xproperties; | |
3150 | |
3151 public: | |
3152 axes (const graphics_handle& mh, const graphics_handle& p) | |
3153 : base_graphics_object (), xproperties (mh, p), default_properties () | |
3154 { | |
3155 xproperties.override_defaults (*this); | |
7830
61aee739a4da
Make sure to initialize axes xform data.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
3156 xproperties.update_transform (); |
6874 | 3157 } |
3158 | |
3159 ~axes (void) { xproperties.delete_children (); } | |
3160 | |
3161 void override_defaults (base_graphics_object& obj) | |
3162 { | |
3163 // Allow parent (figure) to override first (properties knows how | |
3164 // to find the parent object). | |
3165 xproperties.override_defaults (obj); | |
3166 | |
3167 // Now override with our defaults. If the default_properties | |
3168 // list includes the properties for all defaults (line, | |
3169 // surface, etc.) then we don't have to know the type of OBJ | |
3170 // here, we just call its set function and let it decide which | |
3171 // properties from the list to use. | |
3172 obj.set_from_list (default_properties); | |
3173 } | |
3174 | |
7189 | 3175 void set (const caseless_str& name, const octave_value& value) |
6874 | 3176 { |
3177 if (name.compare ("default", 7)) | |
3178 // strip "default", pass rest to function that will | |
3179 // parse the remainder and add the element to the | |
3180 // default_properties map. | |
3181 default_properties.set (name.substr (7), value); | |
3182 else | |
3183 xproperties.set (name, value); | |
3184 } | |
3185 | |
3186 void set_defaults (const std::string& mode) | |
3187 { | |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
3188 remove_all_listeners (); |
6874 | 3189 xproperties.set_defaults (*this, mode); |
3190 } | |
3191 | |
7189 | 3192 octave_value get (const caseless_str& name) const |
6874 | 3193 { |
3194 octave_value retval; | |
3195 | |
3196 // FIXME -- finish this. | |
3197 if (name.compare ("default", 7)) | |
3198 retval = get_default (name.substr (7)); | |
3199 else | |
3200 retval = xproperties.get (name); | |
3201 | |
3202 return retval; | |
3203 } | |
3204 | |
7189 | 3205 octave_value get_default (const caseless_str& name) const; |
6874 | 3206 |
3207 octave_value get_defaults (void) const | |
3208 { | |
3209 return default_properties.as_struct ("default"); | |
3210 } | |
3211 | |
3212 base_properties& get_properties (void) { return xproperties; } | |
3213 | |
7222 | 3214 const base_properties& get_properties (void) const { return xproperties; } |
3215 | |
7214 | 3216 void update_axis_limits (const std::string& axis_type); |
3217 | |
6874 | 3218 bool valid_object (void) const { return true; } |
3219 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3220 void reset_default_properties (void); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3221 |
6874 | 3222 private: |
3223 property_list default_properties; | |
3224 }; | |
3225 | |
3226 // --------------------------------------------------------------------- | |
3227 | |
7365 | 3228 class OCTINTERP_API line : public base_graphics_object |
6874 | 3229 { |
3230 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3231 class OCTINTERP_API properties : public base_properties |
6874 | 3232 { |
3233 public: | |
3234 // See the genprops.awk script for an explanation of the | |
3235 // properties declarations. | |
3236 | |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10585
diff
changeset
|
3237 // properties which are not in matlab: keylabel, interpreter |
7366 | 3238 |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3239 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
|
3240 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
|
3241 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
|
3242 row_vector_property zdata u , Matrix () |
8257 | 3243 string_property xdatasource , "" |
3244 string_property ydatasource , "" | |
3245 string_property zdatasource , "" | |
7363 | 3246 color_property color , color_values (0, 0, 0) |
3247 radio_property linestyle , "{-}|--|:|-.|none" | |
3248 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
|
3249 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@" |
7363 | 3250 color_property markeredgecolor , "{auto}|none" |
3251 color_property markerfacecolor , "auto|{none}" | |
3252 double_property markersize , 6 | |
3253 string_property keylabel , "" | |
7384 | 3254 radio_property interpreter , "{tex}|none|latex" |
7377 | 3255 string_property displayname , "" |
7380 | 3256 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
|
3257 // 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
|
3258 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
|
3259 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
|
3260 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
|
3261 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
|
3262 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
|
3263 bool_property zliminclude hl , "off" |
6874 | 3264 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
|
3265 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3266 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3267 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
|
3268 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
|
3269 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3270 void update_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
|
3271 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3272 void update_ydata (void) { 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
|
3273 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3274 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
|
3275 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3276 set_zlim (zdata.get_limits ()); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3277 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
|
3278 } |
6874 | 3279 }; |
3280 | |
3281 private: | |
3282 properties xproperties; | |
3283 | |
3284 public: | |
3285 line (const graphics_handle& mh, const graphics_handle& p) | |
3286 : base_graphics_object (), xproperties (mh, p) | |
3287 { | |
3288 xproperties.override_defaults (*this); | |
3289 } | |
3290 | |
3291 ~line (void) { xproperties.delete_children (); } | |
3292 | |
3293 base_properties& get_properties (void) { return xproperties; } | |
3294 | |
7222 | 3295 const base_properties& get_properties (void) const { return xproperties; } |
3296 | |
6874 | 3297 bool valid_object (void) const { return true; } |
3298 }; | |
3299 | |
3300 // --------------------------------------------------------------------- | |
3301 | |
7365 | 3302 class OCTINTERP_API text : public base_graphics_object |
6874 | 3303 { |
3304 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3305 class OCTINTERP_API properties : public base_properties |
6874 | 3306 { |
3307 public: | |
3308 // See the genprops.awk script for an explanation of the | |
3309 // properties declarations. | |
3310 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3311 BEGIN_PROPERTIES (text) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3312 string_property string u , "" |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3313 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
|
3314 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
|
3315 double_property rotation u , 0 |
7363 | 3316 radio_property horizontalalignment , "{left}|center|right" |
3317 color_property color , color_values (0, 0, 0) | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3318 string_property fontname u , OCTAVE_DEFAULT_FONTNAME |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3319 double_property fontsize u , 10 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3320 radio_property fontangle u , "{normal}|italic|oblique" |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3321 radio_property fontweight u , "light|{normal}|demi|bold" |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3322 radio_property interpreter u , "{tex}|none|latex" |
7377 | 3323 color_property backgroundcolor , "{none}" |
3324 string_property displayname , "" | |
3325 color_property edgecolor , "{none}" | |
7380 | 3326 radio_property erasemode , "{normal}|none|xor|background" |
7377 | 3327 bool_property editing , "off" |
8465 | 3328 radio_property fontunits , "inches|centimeters|normalized|{points}|pixels" |
7377 | 3329 radio_property linestyle , "{-}|--|:|-.|none" |
3330 double_property linewidth , 0.5 | |
3331 double_property margin , 1 | |
3332 radio_property verticalalignment , "top|cap|{middle}|baseline|bottom" | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3333 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
|
3334 // 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
|
3335 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
|
3336 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
|
3337 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
|
3338 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
|
3339 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
|
3340 bool_property zliminclude hl , "off" |
6874 | 3341 END_PROPERTIES |
3342 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3343 Matrix get_data_position (void) const; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3344 |
7363 | 3345 protected: |
3346 void init (void) | |
3347 { | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3348 position.add_constraint (dim_vector (1, 2)); |
7363 | 3349 position.add_constraint (dim_vector (1, 3)); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3350 cached_units = get_units (); |
7363 | 3351 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3352 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3353 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3354 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
|
3355 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3356 Matrix pos = get_data_position (); |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3357 Matrix lim; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3358 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3359 lim = Matrix (1, 3, pos(0)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3360 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3361 set_xlim (lim); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3362 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3363 lim = Matrix (1, 3, pos(1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3364 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3365 set_ylim (lim); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3366 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3367 if (pos.numel () == 3) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3368 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3369 lim = Matrix (1, 3, pos(2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3370 lim(2) = (lim(2) <= 0 ? octave_Inf : lim(2)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3371 set_zliminclude ("on"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3372 set_zlim (lim); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3373 } |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3374 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3375 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
|
3376 } |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3377 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3378 void update_text_extent (void); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3379 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3380 void update_string (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3381 void update_rotation (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3382 void update_fontname (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3383 void update_fontsize (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3384 void update_fontangle (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3385 void update_fontweight (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3386 void update_interpreter (void) { update_text_extent (); } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3387 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3388 void update_units (void); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3389 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3390 private: |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10317
diff
changeset
|
3391 std::string cached_units; |
6874 | 3392 }; |
3393 | |
3394 private: | |
3395 properties xproperties; | |
3396 | |
3397 public: | |
3398 text (const graphics_handle& mh, const graphics_handle& p) | |
3399 : base_graphics_object (), xproperties (mh, p) | |
3400 { | |
3401 xproperties.override_defaults (*this); | |
3402 } | |
3403 | |
3404 ~text (void) { xproperties.delete_children (); } | |
3405 | |
3406 base_properties& get_properties (void) { return xproperties; } | |
3407 | |
7222 | 3408 const base_properties& get_properties (void) const { return xproperties; } |
3409 | |
6874 | 3410 bool valid_object (void) const { return true; } |
3411 }; | |
3412 | |
3413 // --------------------------------------------------------------------- | |
3414 | |
7365 | 3415 class OCTINTERP_API image : public base_graphics_object |
6874 | 3416 { |
3417 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3418 class OCTINTERP_API properties : public base_properties |
6874 | 3419 { |
3420 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
|
3421 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
|
3422 { 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
|
3423 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
|
3424 { 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
|
3425 |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9620
diff
changeset
|
3426 octave_value get_color_data (void) const; |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9620
diff
changeset
|
3427 |
6874 | 3428 // See the genprops.awk script for an explanation of the |
3429 // properties declarations. | |
3430 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3431 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
|
3432 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
|
3433 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
|
3434 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
|
3435 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
|
3436 // 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
|
3437 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
|
3438 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
|
3439 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
|
3440 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
|
3441 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
|
3442 bool_property climinclude hlg , "on" |
6874 | 3443 END_PROPERTIES |
3444 | |
7363 | 3445 protected: |
3446 void init (void) | |
3447 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3448 xdata.add_constraint (2); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3449 ydata.add_constraint (2); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3450 cdata.add_constraint ("double"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3451 cdata.add_constraint ("single"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3452 cdata.add_constraint ("logical"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3453 cdata.add_constraint ("uint8"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3454 cdata.add_constraint ("uint16"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3455 cdata.add_constraint ("int16"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3456 cdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3457 cdata.add_constraint (dim_vector (-1, -1, 3)); |
7363 | 3458 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3459 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3460 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3461 void update_xdata (void) |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3462 { |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3463 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
|
3464 Matrix limits = xdata.get_limits (); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3465 float dp = (limits(1) - limits(0))/(2*iw); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3466 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3467 limits(0) = limits(0) - dp; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3468 limits(1) = limits(1) + dp; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3469 set_xlim (limits); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3470 } |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3471 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3472 void update_ydata (void) |
9687
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3473 { |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3474 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
|
3475 Matrix limits = ydata.get_limits (); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3476 float dp = (limits(1) - limits(0))/(2*ih); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3477 |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3478 limits(0) = limits(0) - dp; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3479 limits(1) = limits(1) + dp; |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3480 set_ylim (limits); |
86aa08bbc887
image clipping and axes fixes
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9680
diff
changeset
|
3481 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3482 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3483 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
|
3484 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3485 if (cdatamapping_is ("scaled")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3486 set_clim (cdata.get_limits ()); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3487 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3488 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
|
3489 } |
6874 | 3490 }; |
3491 | |
3492 private: | |
3493 properties xproperties; | |
3494 | |
3495 public: | |
3496 image (const graphics_handle& mh, const graphics_handle& p) | |
3497 : base_graphics_object (), xproperties (mh, p) | |
3498 { | |
3499 xproperties.override_defaults (*this); | |
3500 } | |
3501 | |
3502 ~image (void) { xproperties.delete_children (); } | |
3503 | |
3504 base_properties& get_properties (void) { return xproperties; } | |
3505 | |
7222 | 3506 const base_properties& get_properties (void) const { return xproperties; } |
3507 | |
6874 | 3508 bool valid_object (void) const { return true; } |
3509 }; | |
3510 | |
3511 // --------------------------------------------------------------------- | |
3512 | |
7365 | 3513 class OCTINTERP_API patch : public base_graphics_object |
6874 | 3514 { |
3515 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3516 class OCTINTERP_API properties : public base_properties |
6874 | 3517 { |
3518 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
|
3519 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
|
3520 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3521 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
|
3522 { 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
|
3523 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
|
3524 { 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
|
3525 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3526 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
|
3527 { 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
|
3528 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
|
3529 { 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
|
3530 |
6874 | 3531 // See the genprops.awk script for an explanation of the |
3532 // properties declarations. | |
3533 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3534 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
|
3535 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
|
3536 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
|
3537 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
|
3538 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
|
3539 radio_property cdatamapping l , "{scaled}|direct" |
7363 | 3540 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
|
3541 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
|
3542 array_property facevertexcdata , Matrix () |
7363 | 3543 array_property vertices , Matrix () |
7368 | 3544 array_property vertexnormals , Matrix () |
7379 | 3545 radio_property normalmode , "{auto}|manual" |
3546 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
|
3547 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
|
3548 radio_property facelighting , "flat|{none}|gouraud|phong" |
7379 | 3549 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
|
3550 double_radio_property edgealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7379 | 3551 radio_property edgelighting , "{none}|flat|gouraud|phong" |
3552 radio_property backfacelighting , "{reverselit}|unlit|lit" | |
7368 | 3553 double_property ambientstrength , 0.3 |
3554 double_property diffusestrength , 0.6 | |
3555 double_property specularstrength , 0.6 | |
3556 double_property specularexponent , 10.0 | |
3557 double_property specularcolorreflectance , 1.0 | |
7379 | 3558 radio_property erasemode , "{normal}|background|xor|none" |
7363 | 3559 radio_property linestyle , "{-}|--|:|-.|none" |
3560 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
|
3561 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
|
3562 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
|
3563 color_property markerfacecolor , "auto|{none}|flat" |
7363 | 3564 double_property markersize , 6 |
3565 string_property keylabel , "" | |
7384 | 3566 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
|
3567 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
|
3568 // 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
|
3569 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
|
3570 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
|
3571 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
|
3572 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
|
3573 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
|
3574 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
|
3575 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
|
3576 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
|
3577 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
|
3578 bool_property aliminclude hlg , "on" |
6874 | 3579 END_PROPERTIES |
3580 | |
7363 | 3581 protected: |
3582 void init (void) | |
3583 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3584 xdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3585 ydata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3586 zdata.add_constraint (dim_vector (-1, -1)); |
7363 | 3587 vertices.add_constraint (dim_vector (-1, 2)); |
3588 vertices.add_constraint (dim_vector (-1, 3)); | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3589 cdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3590 cdata.add_constraint (dim_vector (-1, -1, 3)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3591 facevertexcdata.add_constraint (dim_vector (-1, 1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3592 facevertexcdata.add_constraint (dim_vector (-1, 3)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3593 facevertexalphadata.add_constraint (dim_vector (-1, 1)); |
7363 | 3594 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3595 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3596 private: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3597 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
|
3598 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
|
3599 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
|
3600 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3601 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
|
3602 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3603 if (cdatamapping_is ("scaled")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3604 set_clim (cdata.get_limits ()); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3605 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3606 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
|
3607 } |
6874 | 3608 }; |
3609 | |
3610 private: | |
3611 properties xproperties; | |
3612 | |
3613 public: | |
3614 patch (const graphics_handle& mh, const graphics_handle& p) | |
3615 : base_graphics_object (), xproperties (mh, p) | |
3616 { | |
3617 xproperties.override_defaults (*this); | |
3618 } | |
3619 | |
3620 ~patch (void) { xproperties.delete_children (); } | |
3621 | |
3622 base_properties& get_properties (void) { return xproperties; } | |
3623 | |
7222 | 3624 const base_properties& get_properties (void) const { return xproperties; } |
3625 | |
6874 | 3626 bool valid_object (void) const { return true; } |
3627 }; | |
3628 | |
3629 // --------------------------------------------------------------------- | |
3630 | |
7365 | 3631 class OCTINTERP_API surface : public base_graphics_object |
6874 | 3632 { |
3633 public: | |
7821
f79dcba526a8
Export nested properties classes of all graphics object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7527
diff
changeset
|
3634 class OCTINTERP_API properties : public base_properties |
6874 | 3635 { |
3636 public: | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3637 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
|
3638 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3639 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
|
3640 { 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
|
3641 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
|
3642 { 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
|
3643 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3644 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
|
3645 { 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
|
3646 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
|
3647 { 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
|
3648 |
6874 | 3649 // See the genprops.awk script for an explanation of the |
3650 // properties declarations. | |
3651 | |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3652 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
|
3653 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
|
3654 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
|
3655 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
|
3656 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
|
3657 radio_property cdatamapping al , "{scaled}|direct" |
8257 | 3658 string_property xdatasource , "" |
3659 string_property ydatasource , "" | |
3660 string_property zdatasource , "" | |
3661 string_property cdatasource , "" | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3662 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
|
3663 double_radio_property facealpha , double_radio_property (1.0, radio_values ("flat|interp")) |
7379 | 3664 color_property edgecolor , color_property (color_values (0, 0, 0), radio_values ("flat|none|interp")) |
7363 | 3665 radio_property linestyle , "{-}|--|:|-.|none" |
3666 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
|
3667 radio_property marker , "{none}|s|o|x|+|.|*|<|>|v|^|d|p|h|@" |
7363 | 3668 color_property markeredgecolor , "{auto}|none" |
3669 color_property markerfacecolor , "auto|{none}" | |
3670 double_property markersize , 6 | |
3671 string_property keylabel , "" | |
7384 | 3672 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
|
3673 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
|
3674 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
|
3675 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
|
3676 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
|
3677 double_property diffusestrength , 0.6 |
7846
d7737a4268b7
Fix typos in property names (edgealpha/facealpha).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
3678 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
|
3679 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
|
3680 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
|
3681 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
|
3682 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
|
3683 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
|
3684 double_property specularcolorreflectance , 1 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3685 double_property specularexponent , 10 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3686 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
|
3687 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
|
3688 // 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
|
3689 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
|
3690 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
|
3691 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
|
3692 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
|
3693 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
|
3694 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
|
3695 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
|
3696 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
|
3697 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
|
3698 bool_property aliminclude hlg , "on" |
6874 | 3699 END_PROPERTIES |
3700 | |
7363 | 3701 protected: |
3702 void init (void) | |
3703 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3704 xdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3705 ydata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3706 zdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3707 alphadata.add_constraint ("double"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3708 alphadata.add_constraint ("uint8"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3709 alphadata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3710 vertexnormals.add_constraint (dim_vector (-1, -1, 3)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3711 cdata.add_constraint ("double"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3712 cdata.add_constraint ("uint8"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3713 cdata.add_constraint (dim_vector (-1, -1)); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3714 cdata.add_constraint (dim_vector (-1, -1, 3)); |
7363 | 3715 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3716 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3717 private: |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3718 void update_normals (void); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3719 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3720 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
|
3721 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3722 update_normals (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3723 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
|
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_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
|
3727 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3728 update_normals (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3729 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
|
3730 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3731 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3732 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
|
3733 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3734 update_normals (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3735 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
|
3736 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3737 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3738 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
|
3739 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3740 if (cdatamapping_is ("scaled")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3741 set_clim (cdata.get_limits ()); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3742 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3743 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
|
3744 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3745 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
3746 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
|
3747 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3748 if (alphadatamapping_is ("scaled")) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3749 set_alim (alphadata.get_limits ()); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3750 else |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3751 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
|
3752 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3753 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3754 void update_normalmode (void) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3755 { update_normals (); } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3756 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3757 void update_vertexnormals (void) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
3758 { set_normalmode ("manual"); } |
6874 | 3759 }; |
3760 | |
3761 private: | |
3762 properties xproperties; | |
3763 | |
3764 public: | |
3765 surface (const graphics_handle& mh, const graphics_handle& p) | |
3766 : base_graphics_object (), xproperties (mh, p) | |
3767 { | |
3768 xproperties.override_defaults (*this); | |
3769 } | |
3770 | |
3771 ~surface (void) { xproperties.delete_children (); } | |
3772 | |
3773 base_properties& get_properties (void) { return xproperties; } | |
3774 | |
7222 | 3775 const base_properties& get_properties (void) const { return xproperties; } |
3776 | |
6874 | 3777 bool valid_object (void) const { return true; } |
3778 }; | |
3779 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3780 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3781 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3782 class OCTINTERP_API hggroup : public base_graphics_object |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3783 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3784 public: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3785 class OCTINTERP_API properties : public base_properties |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3786 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3787 public: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3788 void remove_child (const graphics_handle& h) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3789 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3790 base_properties::remove_child (h); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3791 update_limits (); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3792 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3793 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3794 void adopt (const graphics_handle& h) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3795 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3796 base_properties::adopt (h); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3797 update_limits (); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3798 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3799 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3800 // 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
|
3801 // properties declarations. |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3802 |
8247
e41f420875db
set name of root_figure object to root
John W. Eaton <jwe@octave.org>
parents:
8222
diff
changeset
|
3803 BEGIN_PROPERTIES (hggroup) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3804 // hidden properties for limit computation |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3805 row_vector_property xlim hr , Matrix() |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3806 row_vector_property ylim hr , Matrix() |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3807 row_vector_property zlim hr , Matrix() |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3808 row_vector_property clim hr , Matrix() |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3809 row_vector_property alim hr , Matrix() |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3810 bool_property xliminclude h , "on" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3811 bool_property yliminclude h , "on" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3812 bool_property zliminclude h , "on" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3813 bool_property climinclude h , "on" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3814 bool_property aliminclude h , "on" |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3815 END_PROPERTIES |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3816 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3817 private: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3818 void update_limits (void) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3819 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3820 update_axis_limits ("xlim"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3821 update_axis_limits ("ylim"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3822 update_axis_limits ("zlim"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3823 update_axis_limits ("clim"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3824 update_axis_limits ("alim"); |
7865
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 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3827 protected: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3828 void init (void) |
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 }; |
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 private: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3833 properties xproperties; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3834 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3835 public: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3836 hggroup (const graphics_handle& mh, const graphics_handle& p) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3837 : base_graphics_object (), xproperties (mh, p) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3838 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3839 xproperties.override_defaults (*this); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3840 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3841 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3842 ~hggroup (void) { xproperties.delete_children (); } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3843 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3844 base_properties& get_properties (void) { return xproperties; } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3845 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3846 const base_properties& get_properties (void) const { return xproperties; } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3847 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3848 bool valid_object (void) const { return true; } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3849 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3850 void update_axis_limits (const std::string& axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3851 }; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3852 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3853 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
3854 |
6874 | 3855 octave_value |
3856 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
|
3857 const std::string &func); |
6874 | 3858 bool |
3859 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
|
3860 const octave_value &arg, const std::string &func); |
6874 | 3861 |
3862 // --------------------------------------------------------------------- | |
3863 | |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3864 class graphics_event; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3865 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3866 class |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3867 base_graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3868 { |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3869 public: |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3870 friend class graphics_event; |
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 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
|
3873 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3874 virtual ~base_graphics_event (void) { } |
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 virtual void execute (void) = 0; |
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 private: |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3879 int count; |
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 class |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3883 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3884 { |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3885 public: |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3886 typedef void (*event_fcn) (void*); |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3887 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3888 graphics_event (void) : rep (0) { } |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3889 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3890 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
|
3891 { |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3892 rep = e.rep; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3893 rep->count++; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3894 } |
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 ~graphics_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3897 { |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3898 if (rep && --rep->count == 0) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3899 delete rep; |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3900 } |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3901 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3902 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
|
3903 { |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3904 if (rep != e.rep) |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3905 { |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3906 if (rep && --rep->count == 0) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3907 delete rep; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3908 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3909 rep = e.rep; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3910 if (rep) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3911 rep->count++; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3912 } |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3913 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3914 return *this; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3915 } |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3916 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3917 void execute (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3918 { if (rep) rep->execute (); } |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3919 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3920 bool ok (void) const |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3921 { return (rep != 0); } |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3922 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3923 static graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3924 create_callback_event (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3925 const std::string& name, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3926 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
|
3927 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3928 static graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3929 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
|
3930 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3931 static graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3932 create_set_event (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3933 const std::string& name, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3934 const octave_value& value); |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3935 private: |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3936 base_graphics_event *rep; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3937 }; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
3938 |
7365 | 3939 class OCTINTERP_API gh_manager |
6874 | 3940 { |
3941 protected: | |
3942 | |
3943 gh_manager (void); | |
3944 | |
3945 public: | |
3946 | |
3947 static bool instance_ok (void) | |
3948 { | |
3949 bool retval = true; | |
3950 | |
3951 if (! instance) | |
3952 instance = new gh_manager (); | |
3953 | |
3954 if (! instance) | |
3955 { | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3956 ::error ("unable to create gh_manager!"); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3957 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3958 retval = false; |
6874 | 3959 } |
3960 | |
3961 return retval; | |
3962 } | |
3963 | |
3964 static void free (const graphics_handle& h) | |
3965 { | |
3966 if (instance_ok ()) | |
3967 instance->do_free (h); | |
3968 } | |
3969 | |
3970 static graphics_handle lookup (double val) | |
3971 { | |
3972 return instance_ok () ? instance->do_lookup (val) : graphics_handle (); | |
3973 } | |
3974 | |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10161
diff
changeset
|
3975 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
|
3976 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10161
diff
changeset
|
3977 return val.is_real_scalar () |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10161
diff
changeset
|
3978 ? lookup (val.double_value ()) : graphics_handle (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10161
diff
changeset
|
3979 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10161
diff
changeset
|
3980 |
6874 | 3981 static graphics_object get_object (const graphics_handle& h) |
3982 { | |
3983 return instance_ok () ? instance->do_get_object (h) : graphics_object (); | |
3984 } | |
3985 | |
3986 static graphics_handle | |
3987 make_graphics_handle (const std::string& go_name, | |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
3988 const graphics_handle& parent, bool do_createfcn = true) |
6874 | 3989 { |
3990 return instance_ok () | |
7370 | 3991 ? instance->do_make_graphics_handle (go_name, parent, do_createfcn) |
6874 | 3992 : graphics_handle (); |
3993 } | |
3994 | |
3995 static graphics_handle make_figure_handle (double val) | |
3996 { | |
3997 return instance_ok () | |
3998 ? instance->do_make_figure_handle (val) : graphics_handle (); | |
3999 } | |
4000 | |
4001 static void push_figure (const graphics_handle& h) | |
4002 { | |
4003 if (instance_ok ()) | |
4004 instance->do_push_figure (h); | |
4005 } | |
4006 | |
4007 static void pop_figure (const graphics_handle& h) | |
4008 { | |
4009 if (instance_ok ()) | |
4010 instance->do_pop_figure (h); | |
4011 } | |
4012 | |
4013 static graphics_handle current_figure (void) | |
4014 { | |
4015 return instance_ok () | |
4016 ? instance->do_current_figure () : graphics_handle (); | |
4017 } | |
4018 | |
4019 static Matrix handle_list (void) | |
4020 { | |
4021 return instance_ok () ? instance->do_handle_list () : Matrix (); | |
4022 } | |
4023 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4024 static void lock (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4025 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4026 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4027 instance->do_lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4028 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4029 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4030 static void unlock (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4031 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4032 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4033 instance->do_unlock (); |
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 |
6874 | 4036 static Matrix figure_handle_list (void) |
4037 { | |
4038 return instance_ok () ? instance->do_figure_handle_list () : Matrix (); | |
4039 } | |
4040 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4041 static void execute_callback (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4042 const std::string& name, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4043 const octave_value& data = Matrix ()) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4044 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4045 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4046 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4047 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4048 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4049 octave_value cb = go.get (name); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4050 |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4051 if (! error_state) |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4052 execute_callback (h, cb, data); |
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 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4055 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4056 static void execute_callback (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4057 const octave_value& cb, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4058 const octave_value& data = Matrix ()) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4059 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4060 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4061 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
|
4062 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4063 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4064 static void post_callback (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4065 const std::string& name, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4066 const octave_value& data = Matrix ()) |
7936
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 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4069 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
|
4070 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4071 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
4072 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
|
4073 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4074 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4075 instance->do_post_function (fcn, data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4076 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4077 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4078 static void post_set (const graphics_handle& h, |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4079 const std::string& name, |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4080 const octave_value& value) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4081 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4082 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4083 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
|
4084 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4085 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4086 static int process_events (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4087 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4088 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
|
4089 } |
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 static int flush_events (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4092 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4093 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
|
4094 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4095 |
8249 | 4096 static bool is_handle_visible (const graphics_handle& h) |
4097 { | |
4098 bool retval = false; | |
4099 | |
4100 graphics_object go = get_object (h); | |
4101 | |
4102 if (go.valid_object ()) | |
4103 retval = go.is_handle_visible (); | |
4104 | |
4105 return retval; | |
4106 } | |
4107 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4108 public: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4109 class autolock |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4110 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4111 public: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4112 autolock (void) { lock (); } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4113 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4114 ~autolock (void) { unlock (); } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4115 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4116 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4117 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4118 // No copying! |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4119 autolock (const autolock&); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4120 autolock& operator = (const autolock&); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4121 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4122 |
6874 | 4123 private: |
4124 | |
4125 static gh_manager *instance; | |
4126 | |
4127 typedef std::map<graphics_handle, graphics_object>::iterator iterator; | |
4128 typedef std::map<graphics_handle, graphics_object>::const_iterator const_iterator; | |
4129 | |
4130 typedef std::set<graphics_handle>::iterator free_list_iterator; | |
4131 typedef std::set<graphics_handle>::const_iterator const_free_list_iterator; | |
4132 | |
4133 typedef std::list<graphics_handle>::iterator figure_list_iterator; | |
4134 typedef std::list<graphics_handle>::const_iterator const_figure_list_iterator; | |
4135 | |
4136 // A map of handles to graphics objects. | |
4137 std::map<graphics_handle, graphics_object> handle_map; | |
4138 | |
4139 // The available graphics handles. | |
4140 std::set<graphics_handle> handle_free_list; | |
4141 | |
4142 // The next handle available if handle_free_list is empty. | |
7286 | 4143 double next_handle; |
6874 | 4144 |
4145 // The allocated figure handles. Top of the stack is most recently | |
4146 // created. | |
4147 std::list<graphics_handle> figure_list; | |
4148 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4149 // 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
|
4150 octave_mutex graphics_lock; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4151 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4152 // 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
|
4153 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
|
4154 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4155 // The stack of callback objects |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4156 std::list<graphics_object> callback_objects; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4157 |
6874 | 4158 graphics_handle get_handle (const std::string& go_name); |
4159 | |
4160 void do_free (const graphics_handle& h); | |
4161 | |
4162 graphics_handle do_lookup (double val) | |
4163 { | |
7363 | 4164 iterator p = (xisnan (val) ? handle_map.end () : handle_map.find (val)); |
6874 | 4165 |
4166 return (p != handle_map.end ()) ? p->first : graphics_handle (); | |
4167 } | |
4168 | |
4169 graphics_object do_get_object (const graphics_handle& h) | |
4170 { | |
7379 | 4171 iterator p = (h.ok () ? handle_map.find (h) : handle_map.end ()); |
6874 | 4172 |
4173 return (p != handle_map.end ()) ? p->second : graphics_object (); | |
4174 } | |
4175 | |
4176 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
|
4177 const graphics_handle& p, bool do_createfcn); |
6874 | 4178 |
4179 graphics_handle do_make_figure_handle (double val); | |
4180 | |
4181 Matrix do_handle_list (void) | |
4182 { | |
4183 Matrix retval (1, handle_map.size ()); | |
4184 octave_idx_type i = 0; | |
4185 for (const_iterator p = handle_map.begin (); p != handle_map.end (); p++) | |
7056 | 4186 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4187 graphics_handle h = p->first; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4188 retval(i++) = h.value (); |
7056 | 4189 } |
6874 | 4190 return retval; |
4191 } | |
4192 | |
4193 Matrix do_figure_handle_list (void) | |
4194 { | |
4195 Matrix retval (1, figure_list.size ()); | |
4196 octave_idx_type i = 0; | |
4197 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
|
4198 p != figure_list.end (); |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4199 p++) |
7056 | 4200 { |
10317
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4201 graphics_handle h = *p; |
42d098307c30
untabify additional source files
John W. Eaton <jwe@octave.org>
parents:
10289
diff
changeset
|
4202 retval(i++) = h.value (); |
7056 | 4203 } |
6874 | 4204 return retval; |
4205 } | |
4206 | |
4207 void do_push_figure (const graphics_handle& h); | |
4208 | |
4209 void do_pop_figure (const graphics_handle& h); | |
4210 | |
4211 graphics_handle do_current_figure (void) const | |
4212 { | |
4213 return figure_list.empty () ? graphics_handle () : figure_list.front (); | |
4214 } | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4215 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4216 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
|
4217 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4218 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
|
4219 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4220 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
|
4221 const octave_value& data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4222 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4223 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
|
4224 const octave_value& data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4225 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
4226 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
|
4227 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4228 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
|
4229 const octave_value& value); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4230 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4231 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
|
4232 |
9397
394c7adb488f
graphics.h.in (gh_manager::restore_gcbo): fix decl for unwind-protect
John W. Eaton <jwe@octave.org>
parents:
9347
diff
changeset
|
4233 static void restore_gcbo (void) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4234 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4235 if (instance_ok ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4236 instance->do_restore_gcbo (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4237 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4238 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4239 void do_restore_gcbo (void); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7902
diff
changeset
|
4240 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
4241 void do_post_event (const graphics_event& e); |
6874 | 4242 }; |
4243 | |
9455 | 4244 void get_children_limits (double& min_val, double& max_val, double& min_pos, |
4245 const Matrix& kids, char limit_type); | |
6874 | 4246 |
4247 // This function is NOT equivalent to the scripting language function gcf. | |
7365 | 4248 OCTINTERP_API graphics_handle gcf (void); |
6874 | 4249 |
4250 // This function is NOT equivalent to the scripting language function gca. | |
7365 | 4251 OCTINTERP_API graphics_handle gca (void); |
6874 | 4252 |
4253 #endif |