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