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