Mercurial > octave-dspies
annotate src/graphics.cc @ 11167:51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
author | Konstantinos Poulios <logari81@googlemail.com> |
---|---|
date | Thu, 28 Oct 2010 14:12:46 +0200 |
parents | 31e7e9f94850 |
children | 36442102c340 |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
8920 | 3 Copyright (C) 2007, 2008, 2009 John W. Eaton |
6406 | 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. | |
6406 | 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/>. | |
6406 | 20 |
21 */ | |
22 | |
23 #ifdef HAVE_CONFIG_H | |
24 #include <config.h> | |
25 #endif | |
26 | |
27 #include <cctype> | |
7222 | 28 #include <cfloat> |
7286 | 29 #include <cstdlib> |
6406 | 30 |
31 #include <algorithm> | |
32 #include <list> | |
33 #include <map> | |
34 #include <set> | |
35 #include <string> | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
36 #include <sstream> |
6406 | 37 |
7409 | 38 #include "file-ops.h" |
39 #include "file-stat.h" | |
40 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
41 #include "cmd-edit.h" |
6705 | 42 #include "defun.h" |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
43 #include "display.h" |
6705 | 44 #include "error.h" |
6595 | 45 #include "graphics.h" |
7409 | 46 #include "input.h" |
6705 | 47 #include "ov.h" |
48 #include "oct-obj.h" | |
49 #include "oct-map.h" | |
50 #include "ov-fcn-handle.h" | |
51 #include "parse.h" | |
7409 | 52 #include "toplev.h" |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
53 #include "txt-eng-ft.h" |
7222 | 54 #include "unwind-prot.h" |
6595 | 55 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
56 // forward declarations |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
57 static octave_value xget (const graphics_handle& h, const caseless_str& name); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
58 graphics_object xget_ancestor (const graphics_object& go_arg, |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
59 const std::string& type); |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
60 |
6406 | 61 static void |
62 gripe_set_invalid (const std::string& pname) | |
63 { | |
64 error ("set: invalid value for %s property", pname.c_str ()); | |
65 } | |
66 | |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
67 // Check to see that PNAME matches just one of PNAMES uniquely. |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
68 // Return the full name of the match, or an empty caseless_str object |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
69 // if there is no match, or the match is ambiguous. |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
70 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
71 static caseless_str |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
72 validate_property_name (const std::string& who, const std::string& what, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
73 const std::set<std::string>& pnames, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
74 const caseless_str& pname) |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
75 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
76 size_t len = pname.length (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
77 std::set<std::string> matches; |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
78 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
79 for (std::set<std::string>::const_iterator p = pnames.begin (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
80 p != pnames.end (); p++) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
81 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
82 if (pname.compare (*p, len)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
83 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
84 if (len == p->length ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
85 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
86 // Exact match. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
87 return pname; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
88 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
89 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
90 matches.insert (*p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
91 } |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
92 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
93 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
94 size_t num_matches = matches.size (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
95 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
96 if (num_matches == 0) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
97 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
98 error ("%s: unknown %s property %s", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
99 who.c_str (), what.c_str (), pname.c_str ()); |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
100 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
101 else if (num_matches > 1) |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
102 { |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
103 string_vector sv (matches); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
104 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
105 std::ostringstream os; |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
106 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
107 sv.list_in_columns (os); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
108 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
109 std::string match_list = os.str (); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
110 |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
111 error ("%s: ambiguous %s property name %s; possible matches:\n\n%s", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
112 who.c_str (), what.c_str (), pname.c_str (), match_list.c_str ()); |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
113 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
114 else if (num_matches == 1) |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
115 { |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
116 // Exact match was handled above. |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
117 |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
118 std::string possible_match = *(matches.begin ()); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
119 |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
120 warning_with_id ("Octave:abbreviated-property-match", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
121 "%s: allowing %s to match %s property %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
122 who.c_str (), pname.c_str (), what.c_str (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
123 possible_match.c_str ()); |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
124 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
125 return possible_match; |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
126 } |
9584
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
127 |
0fcbfddaa87f
allow abbreviated graphics property names to match, with optional warning
John W. Eaton <jwe@octave.org>
parents:
9582
diff
changeset
|
128 return caseless_str (); |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
129 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
130 |
7363 | 131 static Matrix |
132 jet_colormap (void) | |
133 { | |
134 Matrix cmap (64, 3, 0.0); | |
135 | |
136 for (octave_idx_type i = 0; i < 64; i++) | |
137 { | |
138 // This is the jet colormap. It would be nice to be able | |
139 // to feval the jet function but since there is a static | |
140 // property object that includes a colormap_property | |
141 // object, we need to initialize this before main is even | |
142 // called, so calling an interpreted function is not | |
143 // possible. | |
144 | |
145 double x = i / 63.0; | |
146 | |
147 if (x >= 3.0/8.0 && x < 5.0/8.0) | |
148 cmap(i,0) = 4.0 * x - 3.0/2.0; | |
149 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
150 cmap(i,0) = 1.0; | |
151 else if (x >= 7.0/8.0) | |
152 cmap(i,0) = -4.0 * x + 9.0/2.0; | |
153 | |
154 if (x >= 1.0/8.0 && x < 3.0/8.0) | |
155 cmap(i,1) = 4.0 * x - 1.0/2.0; | |
156 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
157 cmap(i,1) = 1.0; | |
158 else if (x >= 5.0/8.0 && x < 7.0/8.0) | |
159 cmap(i,1) = -4.0 * x + 7.0/2.0; | |
160 | |
161 if (x < 1.0/8.0) | |
162 cmap(i,2) = 4.0 * x + 1.0/2.0; | |
163 else if (x >= 1.0/8.0 && x < 3.0/8.0) | |
164 cmap(i,2) = 1.0; | |
165 else if (x >= 3.0/8.0 && x < 5.0/8.0) | |
166 cmap(i,2) = -4.0 * x + 5.0/2.0; | |
167 } | |
168 | |
169 return cmap; | |
170 } | |
171 | |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
172 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
173 default_screendepth (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
174 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
175 return display_info::depth (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
176 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
177 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
178 static Matrix |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
179 default_screensize (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
180 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
181 Matrix retval (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
182 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
183 retval(2) = display_info::width (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
184 retval(3) = display_info::height (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
185 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
186 return retval; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
187 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
188 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
189 static double |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
190 default_screenpixelsperinch (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
191 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
192 return (display_info::x_dpi () + display_info::y_dpi ()) / 2; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
193 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
194 |
7363 | 195 static Matrix |
196 default_colororder (void) | |
197 { | |
198 Matrix retval (7, 3, 0.0); | |
199 | |
200 retval(0,2) = 1.0; | |
201 | |
202 retval(1,1) = 0.5; | |
203 | |
204 retval(2,0) = 1.0; | |
205 | |
206 retval(3,1) = 0.75; | |
207 retval(3,2) = 0.75; | |
208 | |
209 retval(4,0) = 0.75; | |
210 retval(4,2) = 0.75; | |
211 | |
212 retval(5,0) = 0.75; | |
213 retval(5,1) = 0.75; | |
214 | |
215 retval(6,0) = 0.25; | |
216 retval(6,1) = 0.25; | |
217 retval(6,2) = 0.25; | |
218 | |
219 return retval; | |
220 } | |
221 | |
222 static Matrix | |
223 default_lim (void) | |
224 { | |
225 Matrix m (1, 2, 0); | |
226 m(1) = 1; | |
227 return m; | |
228 } | |
229 | |
230 static Matrix | |
231 default_data (void) | |
232 { | |
233 Matrix retval (1, 2); | |
234 | |
235 retval(0) = 0; | |
236 retval(1) = 1; | |
237 | |
238 return retval; | |
239 } | |
240 | |
7427 | 241 static Matrix |
242 default_axes_position (void) | |
243 { | |
244 Matrix m (1, 4, 0.0); | |
245 m(0) = 0.13; | |
246 m(1) = 0.11; | |
247 m(2) = 0.775; | |
248 m(3) = 0.815; | |
249 return m; | |
250 } | |
251 | |
252 static Matrix | |
253 default_axes_outerposition (void) | |
254 { | |
255 Matrix m (1, 4, 0.0); | |
256 m(2) = m(3) = 1.0; | |
257 return m; | |
258 } | |
259 | |
7445 | 260 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
261 default_axes_tick (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
262 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
263 Matrix m (1, 6, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
264 m(0) = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
265 m(1) = 0.2; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
266 m(2) = 0.4; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
267 m(3) = 0.6; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
268 m(4) = 0.8; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
269 m(5) = 1.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
270 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
271 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
272 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
273 static Matrix |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
274 default_axes_ticklength (void) |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
275 { |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
276 Matrix m (1, 2, 0.01); |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
277 m(1) = 0.025; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
278 return m; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
279 } |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
280 |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
281 static Matrix |
7445 | 282 default_figure_position (void) |
283 { | |
284 Matrix m (1, 4, 0.0); | |
285 m(0) = 300; | |
286 m(1) = 200; | |
287 m(2) = 560; | |
288 m(3) = 420; | |
289 return m; | |
290 } | |
291 | |
7427 | 292 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
293 default_figure_papersize (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
294 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
295 Matrix m (1, 2, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
296 m(0) = 8.5; |
8961
6b87f2f34fdd
graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents:
8944
diff
changeset
|
297 m(1) = 11.0; |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
298 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
299 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
300 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
301 static Matrix |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
302 default_figure_paperposition (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
303 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
304 Matrix m (1, 4, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
305 m(0) = 0.25; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
306 m(1) = 2.50; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
307 m(2) = 8.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
308 m(3) = 6.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
309 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
310 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
311 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
312 static Matrix |
7427 | 313 convert_position (const Matrix& pos, const caseless_str& from_units, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
314 const caseless_str& to_units, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
315 const Matrix& parent_dim = Matrix (1, 2, 0.0)) |
7427 | 316 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
317 Matrix retval (1, pos.numel ()); |
7427 | 318 double res = 0; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
319 bool is_rectangle = (pos.numel () == 4); |
7427 | 320 |
321 if (from_units.compare ("pixels")) | |
322 retval = pos; | |
323 else if (from_units.compare ("normalized")) | |
324 { | |
325 retval(0) = pos(0) * parent_dim(0) + 1; | |
326 retval(1) = pos(1) * parent_dim(1) + 1; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
327 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
328 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
329 retval(2) = pos(2) * parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
330 retval(3) = pos(3) * parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
331 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
332 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
333 retval(2) = 0; |
7427 | 334 } |
335 else if (from_units.compare ("characters")) | |
336 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
337 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
338 res = xget (0, "screenpixelsperinch").double_value (); |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
339 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
340 double f = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
341 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
342 // FIXME -- this assumes the system font is Helvetica 10pt |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
343 // (for which "x" requires 6x12 pixels at 74.951 pixels/inch) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
344 f = 12.0 * res / 74.951; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
345 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
346 if (f > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
347 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
348 retval(0) = 0.5 * pos(0) * f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
349 retval(1) = pos(1) * f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
350 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
351 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
352 retval(2) = 0.5 * pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
353 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
354 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
355 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
356 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
357 } |
7427 | 358 } |
359 else | |
360 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
361 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
362 res = xget (0, "screenpixelsperinch").double_value (); |
7427 | 363 |
364 double f = 0.0; | |
365 | |
366 if (from_units.compare ("points")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
367 f = res / 72.0; |
7427 | 368 else if (from_units.compare ("inches")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
369 f = res; |
7427 | 370 else if (from_units.compare ("centimeters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
371 f = res / 2.54; |
7427 | 372 |
373 if (f > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
374 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
375 retval(0) = pos(0) * f + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
376 retval(1) = pos(1) * f + 1; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
377 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
378 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
379 retval(2) = pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
380 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
381 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
382 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
383 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
384 } |
7427 | 385 } |
386 | |
387 if (! to_units.compare ("pixels")) | |
388 { | |
389 if (to_units.compare ("normalized")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
390 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
391 retval(0) = (retval(0) - 1) / parent_dim(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
392 retval(1) = (retval(1) - 1) / parent_dim(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
393 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
394 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
395 retval(2) /= parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
396 retval(3) /= parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
397 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
398 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
399 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
400 } |
7427 | 401 else if (to_units.compare ("characters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
402 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
403 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
404 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
405 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
406 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
407 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
408 f = 12.0 * res / 74.951; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
409 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
410 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
411 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
412 retval(0) = 2 * retval(0) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
413 retval(1) = retval(1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
414 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
415 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
416 retval(2) = 2 * retval(2) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
417 retval(3) = retval(3) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
418 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
419 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
420 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
421 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
422 } |
7427 | 423 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
424 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
425 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
426 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
427 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
428 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
429 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
430 if (to_units.compare ("points")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
431 f = res / 72.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
432 else if (to_units.compare ("inches")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
433 f = res; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
434 else if (to_units.compare ("centimeters")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
435 f = res / 2.54; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
436 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
437 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
438 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
439 retval(0) = (retval(0) - 1) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
440 retval(1) = (retval(1) - 1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
441 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
442 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
443 retval(2) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
444 retval(3) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
445 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
446 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
447 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
448 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
449 } |
7427 | 450 } |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
451 else if (! is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
452 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
453 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
454 return retval; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
455 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
456 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
457 static Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
458 convert_text_position (const Matrix& pos, const text::properties& props, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
459 const caseless_str& from_units, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
460 const caseless_str& to_units) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
461 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
462 graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
463 graphics_object ax = xget_ancestor (go, "axes"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
464 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
465 Matrix retval (1, pos.numel (), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
466 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
467 if (ax.valid_object ()) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
468 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
469 const axes::properties& ax_props = |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
470 dynamic_cast<const axes::properties&> (ax.get_properties ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
471 graphics_xform ax_xform = ax_props.get_transform (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
472 bool is_rectangle = (pos.numel () == 4); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
473 Matrix ax_bbox = ax_props.get_boundingbox (true), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
474 ax_size = ax_bbox.extract_n (0, 2, 1, 2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
475 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
476 if (from_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
477 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
478 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
479 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
480 ColumnVector v1 = ax_xform.transform (pos(0), pos(1), 0), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
481 v2 = ax_xform.transform (pos(0) + pos(2), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
482 pos(1) + pos(3), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
483 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
484 retval(0) = v1(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
485 retval(1) = ax_bbox(1) + ax_bbox(3) - v1(1) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
486 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
487 retval(3) = v1(1) - v2(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
488 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
489 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
490 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
491 ColumnVector v = ax_xform.transform (pos(0), pos(1), pos(2)); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
492 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
493 retval(0) = v(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
494 retval(1) = ax_bbox(1) + ax_bbox(3) - v(1) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
495 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
496 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
497 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
498 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
499 retval = convert_position (pos, from_units, "pixels", ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
500 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
501 if (! to_units.compare ("pixels")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
502 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
503 if (to_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
504 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
505 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
506 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
507 ColumnVector v1 = ax_xform.untransform (retval(0) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
508 ax_bbox(1) + ax_bbox(3) - retval(1) + 1), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
509 v2 = ax_xform.untransform (retval(0) + retval(2) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
510 ax_bbox(1) + ax_bbox(3) - (retval(1) + retval(3)) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
511 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
512 retval(0) = v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
513 retval(1) = v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
514 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
515 retval(3) = v2(1) - v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
516 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
517 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
518 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
519 ColumnVector v = ax_xform.untransform (retval(0) + ax_bbox(0) - 1, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
520 ax_bbox(1) + ax_bbox(3) - retval(1) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
521 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
522 retval(0) = v(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
523 retval(1) = v(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
524 retval(2) = v(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
525 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
526 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
527 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
528 retval = convert_position (retval, "pixels", to_units, ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
529 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
530 } |
7427 | 531 |
532 return retval; | |
533 } | |
534 | |
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
|
535 // This function always returns the screensize in pixels |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
536 static Matrix |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
537 screen_size_pixels (void) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
538 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
539 graphics_object obj = gh_manager::get_object (0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
540 Matrix sz = obj.get ("screensize").matrix_value (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
541 return convert_position (sz, obj.get ("units").string_value (), "pixels", sz.extract_n (0, 2, 1, 2)).extract_n (0, 2, 1, 2); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
542 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
543 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
544 graphics_object |
7878
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
545 xget_ancestor (const graphics_object& go_arg, const std::string& type) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
546 { |
7878
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
547 graphics_object go = go_arg; |
b4ac6bb4114b
graphics.cc (execute_callback, xget_ancestor): pass args by const reference and make explicit copies
John W. Eaton <jwe@octave.org>
parents:
7871
diff
changeset
|
548 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
549 do |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
550 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
551 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
552 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
553 if (go.isa (type)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
554 return go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
555 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
556 go = gh_manager::get_object (go.get_parent ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
557 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
558 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
559 return graphics_object (); |
7869 | 560 } |
561 while (true); | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
562 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
563 |
10923
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
564 static void |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
565 convert_cdata_2 (bool is_scaled, double clim_0, double clim_1, |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
566 const double *cmapv, double x, octave_idx_type lda, |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
567 octave_idx_type nc, octave_idx_type i, double *av) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
568 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
569 if (is_scaled) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
570 x = xround ((nc - 1) * (x - clim_0) / (clim_1 - clim_0)); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
571 else |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
572 x = xround (x - 1); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
573 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
574 if (xisnan (x)) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
575 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
576 av[i] = x; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
577 av[i+lda] = x; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
578 av[i+2*lda] = x; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
579 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
580 else |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
581 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
582 if (x < 0) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
583 x = 0; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
584 else if (x >= nc) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
585 x = (nc - 1); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
586 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
587 octave_idx_type idx = static_cast<octave_idx_type> (x); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
588 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
589 av[i] = cmapv[idx]; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
590 av[i+lda] = cmapv[idx+nc]; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
591 av[i+2*lda] = cmapv[idx+2*nc]; |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
592 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
593 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
594 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
595 template <class T> |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
596 void |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
597 convert_cdata_1 (bool is_scaled, double clim_0, double clim_1, |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
598 const double *cmapv, const T *cv, octave_idx_type lda, |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
599 octave_idx_type nc, double *av) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
600 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
601 for (octave_idx_type i = 0; i < lda; i++) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
602 convert_cdata_2 (is_scaled, clim_0, clim_1, cmapv, cv[i], lda, nc, i, av); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
603 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
604 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
605 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
606 convert_cdata (const base_properties& props, const octave_value& cdata, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
607 bool is_scaled, int cdim) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
608 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
609 dim_vector dv (cdata.dims ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
610 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
611 if (dv.length () == cdim && dv(cdim-1) == 3) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
612 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
613 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
614 Matrix cmap (1, 3, 0.0); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
615 Matrix clim (1, 2, 0.0); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
616 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
617 graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
618 graphics_object fig = xget_ancestor (go, "figure"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
619 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
620 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
621 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
622 Matrix _cmap = fig.get (caseless_str ("colormap")).matrix_value (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
623 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
624 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
625 cmap = _cmap; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
626 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
627 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
628 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
629 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
630 graphics_object ax = xget_ancestor (go, "axes"); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
631 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
632 if (ax.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
633 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
634 Matrix _clim = ax.get (caseless_str ("clim")).matrix_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
635 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
636 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
637 clim = _clim; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
638 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
639 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
640 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
641 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
642 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
643 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
644 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
645 |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
646 octave_idx_type lda = a.numel () / static_cast<octave_idx_type> (3); |
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
647 octave_idx_type nc = cmap.rows (); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
648 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
649 double *av = a.fortran_vec (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
650 const double *cmapv = cmap.data (); |
10923
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
651 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
652 double clim_0 = clim(0); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
653 double clim_1 = clim(1); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
654 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
655 #define CONVERT_CDATA_1(ARRAY_T, VAL_FN) \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
656 do \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
657 { \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
658 ARRAY_T tmp = cdata. VAL_FN ## array_value (); \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
659 \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
660 convert_cdata_1 (is_scaled, clim_0, clim_1, cmapv, \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
661 tmp.data (), lda, nc, av); \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
662 } \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
663 while (0) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
664 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
665 if (cdata.is_uint8_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
666 CONVERT_CDATA_1 (uint8NDArray, uint8_); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
667 else if (cdata.is_single_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
668 CONVERT_CDATA_1 (FloatNDArray, float_); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
669 else if (cdata.is_double_type ()) |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
670 CONVERT_CDATA_1 (NDArray, ); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
671 else |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
672 error ("unsupported type for cdata (= %s)", cdata.type_name ().c_str ()); |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
673 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
674 #undef CONVERT_CDATA_1 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
675 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
676 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
677 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
678 |
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
|
679 template<class T> |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
680 static 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
|
681 get_array_limits (const Array<T>& m, double& emin, double& emax, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
682 double& eminp) |
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
|
683 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
684 const T *data = m.data (); |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
685 octave_idx_type n = m.numel (); |
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
686 |
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
687 for (octave_idx_type i = 0; i < n; i++) |
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
|
688 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
689 double e = double (data[i]); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
690 |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
691 if (! (xisinf (e) || xisnan (e))) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
692 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
693 if (e < emin) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
694 emin = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
695 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
696 if (e > emax) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
697 emax = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
698 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
699 if (e > 0 && e < eminp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
700 eminp = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
701 } |
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
|
702 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
703 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
704 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
705 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
706 lookup_object_name (const caseless_str& name, caseless_str& go_name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
707 caseless_str& rest) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
708 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
709 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
710 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
711 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
712 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
713 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
714 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
715 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
716 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
717 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
718 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
719 offset = 4; |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
720 else if (len >= 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
721 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
722 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
723 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
724 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
725 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
726 else if (len >= 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
727 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
728 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
729 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
730 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
731 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
732 else if (len >= 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
733 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
734 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
735 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
736 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
737 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
738 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
739 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
740 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
741 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
742 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
743 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
744 go_name = pfx; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
745 rest = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
746 result = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
747 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
748 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
749 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
750 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
751 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
752 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
753 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
754 make_graphics_object_from_type (const caseless_str& type, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
755 const graphics_handle& h = graphics_handle (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
756 const graphics_handle& p = graphics_handle ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
757 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
758 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
759 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
760 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
761 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
762 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
763 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
764 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
765 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
766 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
767 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
768 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
769 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
770 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
771 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
772 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
773 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
774 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
775 go = new hggroup (h, p); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
776 else if (type.compare ("uimenu")) |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
777 go = new uimenu (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
778 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
779 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
780 |
6406 | 781 // --------------------------------------------------------------------- |
782 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
783 bool |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
784 base_property::set (const octave_value& v, bool do_run ) |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
785 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
786 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
787 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
788 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
789 // notify backend |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
790 if (id >= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
791 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
792 graphics_object go = gh_manager::get_object (parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
793 if (go) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
794 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
795 graphics_backend backend = go.get_backend(); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
796 if (backend) |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
797 backend.update (go, id); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
798 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
799 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
800 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
801 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
802 if (do_run && ! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
803 run_listeners (POSTSET); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
804 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
805 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
806 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
807 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
808 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
809 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
810 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
811 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
812 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
813 base_property::run_listeners (listener_mode mode) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
814 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
815 const octave_value_list& l = listeners[mode]; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
816 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
817 for (int i = 0; i < l.length (); i++) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
818 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
819 gh_manager::execute_callback (parent, l(i), octave_value ()); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
820 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
821 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
822 break; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
823 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
824 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
825 |
6705 | 826 radio_values::radio_values (const std::string& opt_string) |
6406 | 827 { |
6705 | 828 size_t beg = 0; |
829 size_t len = opt_string.length (); | |
830 bool done = len == 0; | |
6681 | 831 |
6705 | 832 while (! done) |
833 { | |
834 size_t end = opt_string.find ('|', beg); | |
6681 | 835 |
6705 | 836 if (end == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
837 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
838 end = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
839 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
840 } |
6681 | 841 |
6705 | 842 std::string t = opt_string.substr (beg, end-beg); |
6681 | 843 |
6705 | 844 // Might want more error checking here... |
845 if (t[0] == '{') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
846 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
847 t = t.substr (1, t.length () - 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
848 default_val = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
849 } |
6705 | 850 else if (beg == 0) // ensure default value |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
851 default_val = t; |
6681 | 852 |
6705 | 853 possible_vals.insert (t); |
6681 | 854 |
6705 | 855 beg = end + 1; |
856 } | |
857 } | |
6681 | 858 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
859 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
860 radio_values::values_as_string (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
861 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
862 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
863 for (std::set<caseless_str>::const_iterator it = possible_vals.begin (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
864 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
865 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
866 if (retval == "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
867 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
868 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
869 retval = "{" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
870 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
871 retval = *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
872 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
873 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
874 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
875 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
876 retval += " | {" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
877 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
878 retval += " | " + *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
879 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
880 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
881 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
882 retval = "[ " + retval + " ]"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
883 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
884 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
885 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
886 Cell |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
887 radio_values::values_as_cell (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
888 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
889 octave_idx_type i = 0; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
890 Cell retval (nelem (), 1); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
891 for (std::set<caseless_str>::const_iterator it = possible_vals.begin (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
892 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
893 retval(i++) = std::string (*it); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
894 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
895 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
896 |
6705 | 897 bool |
6761 | 898 color_values::str2rgb (std::string str) |
6681 | 899 { |
6705 | 900 double tmp_rgb[3] = {0, 0, 0}; |
901 bool retval = true; | |
6761 | 902 unsigned int len = str.length(); |
6681 | 903 |
6925 | 904 std::transform (str.begin (), str.end (), str.begin (), tolower); |
905 | |
6761 | 906 if (str.compare(0, len, "blue", 0, len) == 0) |
907 tmp_rgb[2] = 1; | |
7869 | 908 else if (str.compare(0, len, "black", 0, len) == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
909 || str.compare(0, len, "k", 0, len) == 0) |
6761 | 910 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
911 else if (str.compare(0, len, "red", 0, len) == 0) | |
912 tmp_rgb[0] = 1; | |
913 else if (str.compare(0, len, "green", 0, len) == 0) | |
914 tmp_rgb[1] = 1; | |
915 else if (str.compare(0, len, "yellow", 0, len) == 0) | |
916 tmp_rgb[0] = tmp_rgb[1] = 1; | |
917 else if (str.compare(0, len, "magenta", 0, len) == 0) | |
918 tmp_rgb[0] = tmp_rgb[2] = 1; | |
919 else if (str.compare(0, len, "cyan", 0, len) == 0) | |
920 tmp_rgb[1] = tmp_rgb[2] = 1; | |
7869 | 921 else if (str.compare(0, len, "white", 0, len) == 0 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
922 || str.compare(0, len, "w", 0, len) == 0) |
6761 | 923 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
924 else |
6761 | 925 retval = false; |
6406 | 926 |
6705 | 927 if (retval) |
928 { | |
929 for (int i = 0; i < 3; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
930 xrgb(i) = tmp_rgb[i]; |
6705 | 931 } |
6563 | 932 |
6705 | 933 return retval; |
934 } | |
6681 | 935 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
936 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
937 color_property::do_set (const octave_value& val) |
6790 | 938 { |
939 if (val.is_string ()) | |
940 { | |
941 std::string s = val.string_value (); | |
942 | |
943 if (! s.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
944 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
945 if (radio_val.contains (s)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
946 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
947 if (current_type != radio_t || current_val != s) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
948 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
949 current_val = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
950 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
951 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
952 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
953 } |
6790 | 954 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
955 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
956 color_values col (s); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
957 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
958 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
959 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
960 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
961 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
962 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
963 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
964 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
965 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
966 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
967 error ("invalid value for color property \"%s\" (value = %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
968 get_name ().c_str (), s.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
969 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
970 } |
6790 | 971 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
972 error ("invalid value for color property \"%s\"", |
7363 | 973 get_name ().c_str ()); |
6790 | 974 } |
9311
868fbeb2e365
allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents:
9238
diff
changeset
|
975 else if (val.is_numeric_type ()) |
6790 | 976 { |
977 Matrix m = val.matrix_value (); | |
978 | |
979 if (m.numel () == 3) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
980 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
981 color_values col (m (0), m (1), m(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
982 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
983 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
984 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
985 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
986 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
987 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
988 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
989 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
990 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
991 } |
6790 | 992 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
993 error ("invalid value for color property \"%s\"", |
7363 | 994 get_name ().c_str ()); |
6790 | 995 } |
996 else | |
7363 | 997 error ("invalid value for color property \"%s\"", |
998 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
999 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1000 return false; |
6790 | 1001 } |
1002 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1003 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1004 double_radio_property::do_set (const octave_value& val) |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1005 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1006 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1007 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1008 std::string s = val.string_value (); |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1009 |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1010 if (! s.empty () && radio_val.contains (s)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1011 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1012 if (current_type != radio_t || s != current_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1013 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1014 current_val = s; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1015 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1016 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1017 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1018 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1019 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1020 error ("invalid value for double_radio property \"%s\"", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1021 get_name ().c_str ()); |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1022 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1023 else if (val.is_scalar_type () && val.is_real_type ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1024 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1025 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1026 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1027 if (current_type != double_t || new_dval != dval) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1028 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1029 dval = new_dval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1030 current_type = double_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1031 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1032 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1033 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1034 else |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1035 error ("invalid value for double_radio property \"%s\"", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1036 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1037 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1038 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1039 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1040 |
7363 | 1041 bool |
1042 array_property::validate (const octave_value& v) | |
1043 { | |
7364 | 1044 bool xok = false; |
7363 | 1045 |
8333 | 1046 // FIXME -- should we always support []? |
9181
86ae7e50dc5d
graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
1047 if (v.is_empty () && v.is_numeric_type ()) |
7363 | 1048 return true; |
1049 | |
1050 // check value type | |
1051 if (type_constraints.size () > 0) | |
1052 { | |
1053 for (std::list<std::string>::const_iterator it = type_constraints.begin (); | |
7364 | 1054 ! xok && it != type_constraints.end (); ++it) |
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
|
1055 if ((*it) == v.class_name ()) |
7364 | 1056 xok = true; |
7363 | 1057 } |
1058 else | |
9181
86ae7e50dc5d
graphics.cc (array_property::validate): require value to be numeric, not necessarily double
John W. Eaton <jwe@octave.org>
parents:
9064
diff
changeset
|
1059 xok = v.is_numeric_type (); |
7363 | 1060 |
7364 | 1061 if (xok) |
7363 | 1062 { |
1063 dim_vector vdims = v.dims (); | |
1064 int vlen = vdims.length (); | |
1065 | |
7364 | 1066 xok = false; |
7363 | 1067 |
1068 // check value size | |
1069 if (size_constraints.size () > 0) | |
1070 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); | |
7364 | 1071 ! xok && it != size_constraints.end (); ++it) |
7363 | 1072 { |
1073 dim_vector itdims = (*it); | |
1074 | |
1075 if (itdims.length () == vlen) | |
1076 { | |
7364 | 1077 xok = true; |
7363 | 1078 |
7364 | 1079 for (int i = 0; xok && i < vlen; i++) |
7363 | 1080 if (itdims(i) >= 0 && itdims(i) != vdims(i)) |
7364 | 1081 xok = false; |
7363 | 1082 } |
1083 } | |
1084 else | |
1085 return true; | |
1086 } | |
1087 | |
7364 | 1088 return xok; |
7363 | 1089 } |
1090 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1091 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1092 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1093 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1094 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1095 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1096 if (data.dims () == v.dims ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1097 { |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
1098 |
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
1099 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1100 { \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1101 if (data.numel () == 1) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1102 return data.F ## scalar_value () == \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1103 v.F ## scalar_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1104 else \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1105 { \ |
8075
a028a5960e18
Fix for hold with no figures/axes. Set prop/val pairs to hggroups rather than underlying objects. Fix for equality test in array_property
David Bateman <dbateman@free.fr>
parents:
8063
diff
changeset
|
1106 /* Keep copy of array_value to allow sparse/bool arrays */ \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1107 /* that are converted, to not be deallocated early */ \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1108 const A m1 = data.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1109 const T* d1 = m1.data (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1110 const A m2 = v.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1111 const T* d2 = m2.data ();\ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1112 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1113 bool flag = true; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1114 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1115 for (int i = 0; flag && i < data.numel (); i++) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1116 if (d1[i] != d2[i]) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1117 flag = false; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1118 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1119 return flag; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1120 } \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1121 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1122 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1123 if (data.is_double_type() || data.is_bool_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1124 CHECK_ARRAY_EQUAL (double, , NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1125 else if (data.is_single_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1126 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1127 else if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1128 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1129 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1130 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1131 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1132 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1133 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1134 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1135 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1136 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1137 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1138 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1139 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1140 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1141 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1142 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1143 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1144 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1145 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1146 return false; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1147 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1148 |
7363 | 1149 void |
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
|
1150 array_property::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
|
1151 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1152 xmin = xminp = octave_Inf; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1153 xmax = -octave_Inf; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1154 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1155 if (! data.is_empty ()) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1156 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1157 if (data.is_integer_type ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1158 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1159 if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1160 get_array_limits (data.int8_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1161 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1162 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1163 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1164 get_array_limits (data.int16_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1165 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1166 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1167 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1168 get_array_limits (data.int32_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1169 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1170 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1171 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1172 get_array_limits (data.int64_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1173 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1174 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1175 } |
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
|
1176 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1177 get_array_limits (data.array_value (), xmin, xmax, xminp); |
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
|
1178 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1179 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1180 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1181 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1182 handle_property::do_set (const octave_value& v) |
7363 | 1183 { |
1184 double dv = v.double_value (); | |
1185 | |
1186 if (! error_state) | |
1187 { | |
1188 graphics_handle gh = gh_manager::lookup (dv); | |
1189 | |
1190 if (xisnan (gh.value ()) || gh.ok ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1191 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1192 if (current_val != gh) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1193 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1194 current_val = gh; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1195 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1196 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1197 } |
7363 | 1198 else |
1199 error ("set: invalid graphics handle (= %g) for property \"%s\"", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1200 dv, get_name ().c_str ()); |
7363 | 1201 } |
1202 else | |
1203 error ("set: invalid graphics handle for property \"%s\"", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1204 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1205 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1206 return false; |
7363 | 1207 } |
1208 | |
1209 bool | |
7367 | 1210 callback_property::validate (const octave_value& v) const |
7363 | 1211 { |
7367 | 1212 // case 1: function handle |
1213 // case 2: cell array with first element being a function handle | |
1214 // case 3: string corresponding to known function name | |
1215 // case 4: evaluatable string | |
1216 // case 5: empty matrix | |
1217 | |
1218 if (v.is_function_handle ()) | |
1219 return true; | |
1220 else if (v.is_string ()) | |
1221 // complete validation will be done at execution-time | |
1222 return true; | |
1223 else if (v.is_cell () && v.length () > 0 | |
1224 && (v.rows() == 1 || v.columns () == 1) | |
1225 && v.cell_value ()(0).is_function_handle ()) | |
1226 return true; | |
1227 else if (v.is_empty ()) | |
1228 return true; | |
1229 | |
1230 return false; | |
7363 | 1231 } |
1232 | |
1233 void | |
7367 | 1234 callback_property::execute (const octave_value& data) const |
7363 | 1235 { |
7367 | 1236 if (callback.is_defined () && ! callback.is_empty ()) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
1237 gh_manager::execute_callback (get_parent (), callback, data); |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1238 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1239 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1240 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1241 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1242 static std::map<caseless_str, graphics_object> dprop_obj_map; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1243 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1244 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1245 property::create (const std::string& name, const graphics_handle& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1246 const caseless_str& type, const octave_value_list& args) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1247 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1248 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1249 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1250 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1251 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1252 std::string val = (args.length () > 0 ? args(0).string_value () : ""); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1253 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1254 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1255 retval = property (new string_property (name, h, val)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1256 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1257 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1258 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1259 octave_value val = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1260 (args.length () > 0 ? args(0) : octave_value (Matrix ())); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1261 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1262 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1263 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1264 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1265 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1266 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1267 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1268 std::string vals = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1269 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1270 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1271 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1272 retval = property (new radio_property (name, h, vals)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1273 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1274 if (args.length () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1275 retval.set (args(1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1276 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1277 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1278 error ("addproperty: invalid argument for radio property, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1279 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1280 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1281 error ("addproperty: missing possible values for radio property"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1282 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1283 else if (type.compare ("double")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1284 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1285 double d = (args.length () > 0 ? args(0).double_value () : 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1286 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1287 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1288 retval = property (new double_property (name, h, d)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1289 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1290 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1291 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1292 double hh = (args.length () > 0 ? args(0).double_value () : octave_NaN); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1293 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1294 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1295 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1296 graphics_handle gh (hh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1297 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1298 retval = property (new handle_property (name, h, gh)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1299 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1300 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1301 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1302 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1303 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1304 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1305 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1306 retval.set (args(0)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1307 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1308 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1309 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1310 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1311 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1312 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1313 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1314 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1315 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1316 // FIXME -- additional argument could define constraints, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1317 // but is this really useful? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1318 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1319 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1320 else if (type.compare ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1321 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1322 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1323 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1324 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1325 if (args.length () > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1326 rv = radio_values (args(1).string_value ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1327 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1328 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1329 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1330 retval = property (new color_property (name, h, cv, rv)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1331 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1332 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1333 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1334 if (args.length () > 0 && ! args(0).is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1335 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1336 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1337 retval.set (rv.default_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1338 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1339 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1340 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1341 else |
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 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1344 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1345 if (lookup_object_name (type, go_name, go_rest)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1346 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1347 graphics_object go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1348 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1349 std::map<caseless_str, graphics_object>::const_iterator it = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1350 dprop_obj_map.find (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1351 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1352 if (it == dprop_obj_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1353 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1354 base_graphics_object *bgo = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1355 make_graphics_object_from_type (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1356 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1357 if (bgo) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1358 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1359 go = graphics_object (bgo); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1360 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1361 dprop_obj_map[go_name] = go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1362 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1363 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1364 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1365 go = it->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1366 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1367 if (go.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1368 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1369 property prop = go.get_properties ().get_property (go_rest); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1370 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1371 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1372 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1373 retval = prop.clone (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1374 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1375 retval.set_parent (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1376 retval.set_name (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1377 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1378 if (args.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1379 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1380 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1381 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1382 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1383 error ("addproperty: invalid object type (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1384 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1385 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1386 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1387 error ("addproperty: unsupported type for dynamic property (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1388 type.c_str ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1389 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1390 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1391 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1392 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1393 |
7363 | 1394 // --------------------------------------------------------------------- |
6681 | 1395 |
6705 | 1396 void |
7189 | 1397 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1398 { |
6705 | 1399 size_t offset = 0; |
6681 | 1400 |
6705 | 1401 size_t len = name.length (); |
6681 | 1402 |
6705 | 1403 if (len > 4) |
1404 { | |
7189 | 1405 caseless_str pfx = name.substr (0, 4); |
6681 | 1406 |
6705 | 1407 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1408 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1409 offset = 4; |
6705 | 1410 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1411 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1412 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1413 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1414 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1415 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1416 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1417 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1418 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1419 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1420 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1421 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1422 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1423 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1424 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1425 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1426 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1427 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1428 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1429 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1430 } |
6681 | 1431 |
6705 | 1432 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1433 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1434 // FIXME -- should we validate property names and values here? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1435 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1436 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1437 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1438 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1439 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1440 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1441 bool has_property = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1442 if (pfx == "axes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1443 has_property = axes::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1444 else if (pfx == "line") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1445 has_property = line::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1446 else if (pfx == "text") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1447 has_property = text::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1448 else if (pfx == "image") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1449 has_property = image::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1450 else if (pfx == "patch") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1451 has_property = patch::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1452 else if (pfx == "figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1453 has_property = figure::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1454 else if (pfx == "surface") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1455 has_property = surface::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1456 else if (pfx == "hggroup") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1457 has_property = hggroup::properties::has_core_property (pname); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1458 else if (pfx == "uimenu") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1459 has_property = uimenu::properties::has_core_property (pname); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1460 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1461 if (has_property) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1462 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1463 bool remove = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1464 if (val.is_string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1465 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1466 caseless_str tval = val.string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1467 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1468 remove = tval.compare ("remove"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1469 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1470 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1471 pval_map_type& pval_map = plist_map[pfx]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1472 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1473 if (remove) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1474 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1475 pval_map_iterator p = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1476 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1477 if (p != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1478 pval_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1479 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1480 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1481 pval_map[pname] = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1482 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1483 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1484 error ("invalid %s property `%s'", pfx.c_str (), pname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1485 } |
6705 | 1486 } |
6406 | 1487 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
1488 if (! error_state && offset == 0) |
6705 | 1489 error ("invalid default property specification"); |
1490 } | |
6406 | 1491 |
6705 | 1492 octave_value |
7189 | 1493 property_list::lookup (const caseless_str& name) const |
6705 | 1494 { |
1495 octave_value retval; | |
6406 | 1496 |
6705 | 1497 size_t offset = 0; |
6406 | 1498 |
6705 | 1499 size_t len = name.length (); |
6406 | 1500 |
6705 | 1501 if (len > 4) |
1502 { | |
7189 | 1503 caseless_str pfx = name.substr (0, 4); |
6406 | 1504 |
6705 | 1505 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1506 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1507 offset = 4; |
6705 | 1508 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1509 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1510 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1511 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1512 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1513 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1514 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1515 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1516 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1517 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1518 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1519 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1520 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1521 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1522 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1523 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1524 if (pfx.compare ("surface") || pfx.compare ("hggroup")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1525 offset = 7; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1526 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1527 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1528 } |
6406 | 1529 |
6705 | 1530 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1531 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1532 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1533 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1534 std::transform (pfx.begin (), pfx.end (), pfx.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1535 std::transform (pname.begin (), pname.end (), pname.begin (), tolower); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1536 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1537 plist_map_const_iterator p = find (pfx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1538 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1539 if (p != end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1540 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1541 const pval_map_type& pval_map = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1542 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1543 pval_map_const_iterator q = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1544 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1545 if (q != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1546 retval = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1547 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1548 } |
6705 | 1549 } |
6406 | 1550 |
6705 | 1551 return retval; |
1552 } | |
6406 | 1553 |
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:
10995
diff
changeset
|
1554 octave_scalar_map |
6705 | 1555 property_list::as_struct (const std::string& prefix_arg) const |
1556 { | |
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:
10995
diff
changeset
|
1557 octave_scalar_map m; |
6406 | 1558 |
6705 | 1559 for (plist_map_const_iterator p = begin (); p != end (); p++) |
1560 { | |
1561 std::string prefix = prefix_arg + p->first; | |
6406 | 1562 |
6705 | 1563 const pval_map_type pval_map = p->second; |
6406 | 1564 |
6705 | 1565 for (pval_map_const_iterator q = pval_map.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1566 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1567 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1568 m.assign (prefix + q->first, q->second); |
6705 | 1569 } |
6406 | 1570 |
6705 | 1571 return m; |
1572 } | |
6432 | 1573 |
6874 | 1574 graphics_handle::graphics_handle (const octave_value& a) |
1575 : val (octave_NaN) | |
1576 { | |
1577 if (a.is_empty ()) | |
1578 /* do nothing */; | |
1579 else | |
1580 { | |
1581 double tval = a.double_value (); | |
1582 | |
1583 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1584 val = tval; |
6874 | 1585 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1586 error ("invalid graphics handle"); |
6874 | 1587 } |
1588 } | |
1589 | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1590 // Set properties given as a cs-list of name, value pairs. |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1591 |
6705 | 1592 void |
1593 graphics_object::set (const octave_value_list& args) | |
1594 { | |
1595 int nargin = args.length (); | |
6406 | 1596 |
6705 | 1597 if (nargin == 0) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1598 error ("graphics_object::set: Nothing to set"); |
6705 | 1599 else if (nargin % 2 == 0) |
1600 { | |
1601 for (int i = 0; i < nargin; i += 2) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1602 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1603 caseless_str name = args(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1604 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1605 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1606 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1607 octave_value val = args(i+1); |
6406 | 1608 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1609 set_value_or_default (name, val); |
6406 | 1610 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1611 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1612 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1613 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1614 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1615 error ("set: expecting argument %d to be a property name", i); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1616 } |
6705 | 1617 } |
1618 else | |
1619 error ("set: invalid number of arguments"); | |
1620 } | |
6406 | 1621 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1622 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1623 %!# test set with name, value pairs |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1624 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1625 %! set(gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1626 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1627 %! set (h, "linewidth", 10, "marker", "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1628 %! assert (get (h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1629 %! assert (get (h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1630 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1631 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1632 // Set properties given in two cell arrays containing names and values. |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1633 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1634 graphics_object::set (const Array<std::string>& names, |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1635 const Cell& values, octave_idx_type row) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1636 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1637 if (names.numel () != values.columns ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1638 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1639 error("set: number of names must match number of value columns (%d != %d)", |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1640 names.numel (), values.columns ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1641 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1642 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1643 octave_idx_type k = names.columns (); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1644 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1645 for (octave_idx_type column = 0; column < k; column++) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1646 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1647 caseless_str name = names(column); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1648 octave_value val = values(row, column); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1649 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1650 set_value_or_default (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1651 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1652 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1653 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1654 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1655 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1656 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1657 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1658 %!# test set with cell array arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1659 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1660 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1661 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1662 %! set (h, {"linewidth", "marker"}, {10, "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1663 %! assert (get(h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1664 %! assert (get(h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1665 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1666 %!# test set with multiple handles and cell array arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1667 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1668 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1669 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1670 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1671 %! assert (get (h, "linewidth"), {10; 5}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1672 %! assert (get (h, "marker"), {"x"; "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1673 %! set (h, {"linewidth", "marker"}, {10, "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1674 %! assert (get (h, "linewidth"), {10; 10}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1675 %! assert (get (h, "marker"), {"x"; "x"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1676 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1677 %!error <set: number of graphics handles must match number of value rows> |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1678 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1679 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1680 %! set (h, {"linewidth", "marker"}, {10, "x"; 5, "o"; 7, "."}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1681 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1682 %!error <set: number of names must match number of value columns> |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1683 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1684 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1685 %! set (h, {"linewidth"}, {10, "x"; 5, "o"}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1686 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1687 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1688 // Set properties given in a struct array |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1689 void |
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:
10995
diff
changeset
|
1690 graphics_object::set (const octave_map& m) |
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:
10995
diff
changeset
|
1691 { |
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:
10995
diff
changeset
|
1692 for (octave_map::const_iterator p = m.begin (); |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1693 p != m.end (); p++) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1694 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1695 caseless_str name = m.key (p); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1696 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1697 octave_value val = octave_value (m.contents (p).elem (m.numel () - 1)); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1698 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1699 set_value_or_default (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1700 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1701 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1702 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1703 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1704 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1705 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1706 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1707 %!# test set with struct arguments |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1708 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1709 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1710 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1711 %! set (h, struct ("linewidth", 10, "marker", "x")); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1712 %! assert (get (h, "linewidth"), 10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1713 %! assert (get (h, "marker"), "x"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1714 %! h = plot (1:10, 10:-1:1, 1:10, 1:10); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1715 %! set (h, struct ("linewidth", {5, 10})); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1716 %! assert (get(h, "linewidth"), {10; 10}); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1717 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1718 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1719 // Set a property to a value or to its (factory) default value. |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1720 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1721 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1722 graphics_object::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
|
1723 const octave_value& val) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1724 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1725 if (val.is_string ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1726 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1727 caseless_str tval = val.string_value (); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1728 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1729 octave_value default_val; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1730 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1731 if (tval.compare ("default")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1732 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1733 default_val = get_default (name); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1734 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1735 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1736 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1737 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1738 rep->set (name, default_val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1739 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1740 else if (tval.compare ("factory")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1741 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1742 default_val = get_factory_default (name); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1743 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1744 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1745 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1746 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1747 rep->set (name, default_val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1748 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1749 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1750 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1751 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1752 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1753 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1754 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1755 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1756 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1757 %!# test setting of default values |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1758 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1759 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1760 %! h = plot (1:10, 10:-1:1); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1761 %! set (0, "defaultlinelinewidth", 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1762 %! set (h, "linewidth", "default"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1763 %! assert (get (h, "linewidth"), 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1764 %! set (h, "linewidth", "factory"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1765 %! assert (get (h, "linewidth"), 0.5); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1766 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1767 |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1768 static double |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1769 make_handle_fraction (void) |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1770 { |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1771 static double maxrand = RAND_MAX + 2.0; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1772 |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1773 return (rand () + 1.0) / maxrand; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1774 } |
6406 | 1775 |
6705 | 1776 graphics_handle |
1777 gh_manager::get_handle (const std::string& go_name) | |
1778 { | |
1779 graphics_handle retval; | |
6406 | 1780 |
6705 | 1781 if (go_name == "figure") |
1782 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1783 // Figure handles are positive integers corresponding to the |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1784 // figure number. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1785 |
6705 | 1786 // We always want the lowest unused figure number. |
6406 | 1787 |
6705 | 1788 retval = 1; |
6425 | 1789 |
6705 | 1790 while (handle_map.find (retval) != handle_map.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1791 retval++; |
6705 | 1792 } |
1793 else | |
1794 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1795 // Other graphics handles are negative integers plus some random |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1796 // fractional part. To avoid running out of integers, we |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1797 // recycle the integer part but tack on a new random part each |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1798 // time. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
1799 |
6705 | 1800 free_list_iterator p = handle_free_list.begin (); |
6406 | 1801 |
6705 | 1802 if (p != handle_free_list.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1803 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1804 retval = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1805 handle_free_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1806 } |
6705 | 1807 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1808 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1809 retval = graphics_handle (next_handle); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1810 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1811 next_handle = ceil (next_handle) - 1.0 - make_handle_fraction (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1812 } |
6705 | 1813 } |
6406 | 1814 |
6705 | 1815 return retval; |
1816 } | |
6406 | 1817 |
6705 | 1818 void |
1819 gh_manager::do_free (const graphics_handle& h) | |
1820 { | |
7056 | 1821 if (h.ok ()) |
6705 | 1822 { |
6874 | 1823 if (h.value () != 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1824 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1825 iterator p = handle_map.find (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1826 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1827 if (p != handle_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1828 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1829 base_properties& bp = p->second.get_properties (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1830 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1831 bp.set_beingdeleted (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1832 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1833 bp.delete_children (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1834 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1835 octave_value val = bp.get_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1836 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1837 bp.execute_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1838 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1839 // notify backend |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1840 graphics_backend backend = p->second.get_backend (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1841 if (backend) |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
1842 backend.finalize (p->second); |
8208 | 1843 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1844 // Note: this will be valid only for first explicitly |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1845 // deleted object. All its children will then have an |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1846 // unknown backend. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1847 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1848 // Graphics handles for non-figure objects are negative |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1849 // integers plus some random fractional part. To avoid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1850 // running out of integers, we recycle the integer part |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1851 // but tack on a new random part each time. |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1852 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1853 handle_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1854 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1855 if (h.value () < 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1856 handle_free_list.insert (ceil (h.value ()) - make_handle_fraction ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1857 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1858 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1859 error ("graphics_handle::free: invalid object %g", h.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1860 } |
6705 | 1861 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1862 error ("graphics_handle::free: can't delete root figure"); |
6705 | 1863 } |
1864 } | |
6406 | 1865 |
1866 gh_manager *gh_manager::instance = 0; | |
1867 | |
1868 static void | |
7189 | 1869 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 1870 const octave_value& val) |
1871 { | |
1872 graphics_object obj = gh_manager::get_object (h); | |
1873 obj.set (name, val); | |
1874 } | |
1875 | |
1876 static void | |
1877 xset (const graphics_handle& h, const octave_value_list& args) | |
1878 { | |
1879 if (args.length () > 0) | |
1880 { | |
1881 graphics_object obj = gh_manager::get_object (h); | |
1882 obj.set (args); | |
1883 } | |
1884 } | |
1885 | |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
1886 |
6406 | 1887 static octave_value |
7189 | 1888 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 1889 { |
1890 graphics_object obj = gh_manager::get_object (h); | |
1891 return obj.get (name); | |
1892 } | |
1893 | |
1894 static graphics_handle | |
1895 reparent (const octave_value& ov, const std::string& who, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1896 const std::string& property, const graphics_handle& new_parent, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1897 bool adopt = true) |
6406 | 1898 { |
1899 graphics_handle h = octave_NaN; | |
1900 | |
1901 double val = ov.double_value (); | |
1902 | |
1903 if (! error_state) | |
1904 { | |
1905 h = gh_manager::lookup (val); | |
1906 | |
7056 | 1907 if (h.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1908 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1909 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1910 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1911 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1912 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1913 graphics_object parent_obj = gh_manager::get_object (parent_h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1914 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1915 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1916 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1917 if (adopt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1918 obj.set ("parent", new_parent.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1919 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1920 obj.reparent (new_parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1921 } |
6406 | 1922 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1923 error ("%s: invalid graphics handle (= %g) for %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1924 who.c_str (), val, property.c_str ()); |
6406 | 1925 } |
1926 else | |
1927 error ("%s: expecting %s to be a graphics handle", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1928 who.c_str (), property.c_str ()); |
6406 | 1929 |
1930 return h; | |
1931 } | |
1932 | |
1933 // This function is NOT equivalent to the scripting language function gcf. | |
1934 graphics_handle | |
1935 gcf (void) | |
1936 { | |
1937 octave_value val = xget (0, "currentfigure"); | |
1938 | |
1939 return val.is_empty () ? octave_NaN : val.double_value (); | |
1940 } | |
1941 | |
1942 // This function is NOT equivalent to the scripting language function gca. | |
1943 graphics_handle | |
1944 gca (void) | |
1945 { | |
1946 octave_value val = xget (gcf (), "currentaxes"); | |
1947 | |
1948 return val.is_empty () ? octave_NaN : val.double_value (); | |
1949 } | |
1950 | |
1951 static void | |
1952 adopt (const graphics_handle& p, const graphics_handle& h) | |
1953 { | |
1954 graphics_object parent_obj = gh_manager::get_object (p); | |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
1955 |
6406 | 1956 parent_obj.adopt (h); |
1957 } | |
1958 | |
1959 static bool | |
7056 | 1960 is_handle (const graphics_handle& h) |
1961 { | |
1962 return h.ok (); | |
1963 } | |
1964 | |
1965 static bool | |
6406 | 1966 is_handle (double val) |
1967 { | |
6874 | 1968 graphics_handle h = gh_manager::lookup (val); |
1969 | |
1970 return h.ok (); | |
6406 | 1971 } |
1972 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1973 static octave_value |
6406 | 1974 is_handle (const octave_value& val) |
1975 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1976 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1977 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1978 if (val.is_real_scalar () && is_handle (val.double_value ())) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1979 retval = true; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1980 else if (val.is_real_matrix ()) |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1981 { |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1982 if (val.is_string ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1983 retval = boolNDArray (val.dims (), false); |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1984 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1985 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1986 const NDArray handles = val.array_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1987 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1988 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1989 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1990 boolNDArray result (handles.dims ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1991 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1992 for (octave_idx_type i = 0; i < handles.numel (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1993 result.xelem (i) = is_handle (handles (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1994 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1995 retval = result; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1996 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1997 } |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1998 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
1999 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2000 return retval; |
6406 | 2001 } |
2002 | |
2003 static bool | |
2004 is_figure (double val) | |
2005 { | |
2006 graphics_object obj = gh_manager::get_object (val); | |
2007 | |
2008 return obj && obj.isa ("figure"); | |
2009 } | |
2010 | |
7370 | 2011 static void |
2012 xcreatefcn (const graphics_handle& h) | |
2013 { | |
2014 graphics_object obj = gh_manager::get_object (h); | |
2015 obj.get_properties ().execute_createfcn (); | |
2016 } | |
2017 | |
6406 | 2018 // --------------------------------------------------------------------- |
2019 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2020 void |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2021 base_graphics_backend::update (const graphics_handle& h, int id) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2022 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2023 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2024 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2025 update (go, id); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2026 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2027 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2028 void |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2029 base_graphics_backend::initialize (const graphics_handle& h) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2030 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2031 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2032 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2033 initialize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2034 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2035 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2036 void |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2037 base_graphics_backend::finalize (const graphics_handle& h) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2038 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2039 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2040 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2041 finalize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2042 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2043 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2044 |
6705 | 2045 void |
2046 base_properties::set_from_list (base_graphics_object& obj, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2047 property_list& defaults) |
6406 | 2048 { |
6705 | 2049 std::string go_name = graphics_object_name (); |
6406 | 2050 |
6705 | 2051 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 2052 |
6705 | 2053 if (p != defaults.end ()) |
2054 { | |
2055 const property_list::pval_map_type pval_map = p->second; | |
6406 | 2056 |
6705 | 2057 for (property_list::pval_map_const_iterator q = pval_map.begin (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2058 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2059 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2060 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2061 std::string pname = q->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2062 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2063 obj.set (pname, q->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2064 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2065 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2066 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2067 error ("error setting default property %s", pname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2068 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2069 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2070 } |
6705 | 2071 } |
2072 } | |
6406 | 2073 |
7363 | 2074 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2075 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 2076 { |
2077 octave_value retval; | |
2078 | |
8090 | 2079 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2080 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2081 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2082 retval = it->second.get (); |
7363 | 2083 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2084 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 2085 |
2086 return retval; | |
2087 } | |
2088 | |
2089 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2090 base_properties::get_dynamic (bool all) const |
7363 | 2091 { |
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:
10995
diff
changeset
|
2092 octave_scalar_map m; |
7363 | 2093 |
8090 | 2094 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin (); |
7363 | 2095 it != all_props.end (); ++it) |
7379 | 2096 if (all || ! it->second.is_hidden ()) |
2097 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 2098 |
2099 return m; | |
2100 } | |
2101 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2102 std::set<std::string> |
9972 | 2103 base_properties::dynamic_property_names (void) const |
2104 { | |
2105 return dynamic_properties; | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2106 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2107 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2108 bool |
9972 | 2109 base_properties::has_dynamic_property (const std::string& pname) |
2110 { | |
2111 const std::set<std::string>& dynprops = dynamic_property_names (); | |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2112 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2113 return dynprops.find (pname) != dynprops.end (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2114 } |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2115 |
7363 | 2116 void |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2117 base_properties::set_dynamic (const caseless_str& pname, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2118 const octave_value& val) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2119 { |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2120 std::map<caseless_str, property, cmp_caseless_str>::iterator it = all_props.find (pname); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2121 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2122 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2123 it->second.set (val); |
7363 | 2124 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2125 error ("set: unknown property \"%s\"", pname.c_str ()); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2126 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2127 if (! error_state) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2128 { |
9972 | 2129 dynamic_properties.insert (pname); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2130 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2131 mark_modified (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2132 } |
7363 | 2133 } |
2134 | |
2135 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2136 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 2137 { |
8090 | 2138 std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.find (name); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2139 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2140 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2141 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2142 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2143 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2144 } |
7363 | 2145 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2146 return it->second; |
7363 | 2147 } |
2148 | |
6705 | 2149 void |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2150 base_properties::remove_child (const graphics_handle& h) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2151 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2152 octave_idx_type k = -1; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2153 octave_idx_type n = children.numel (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2154 for (octave_idx_type i = 0; i < n; i++) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2155 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2156 if (h.value () == children(i)) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2157 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2158 k = i; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2159 break; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2160 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2161 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2162 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2163 if (k >= 0) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2164 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2165 Matrix new_kids (n-1, 1); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2166 octave_idx_type j = 0; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2167 for (octave_idx_type i = 0; i < n; i++) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2168 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2169 if (i != k) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2170 new_kids(j++) = children(i); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2171 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2172 children = new_kids; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2173 mark_modified (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2174 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2175 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2176 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2177 void |
6836 | 2178 base_properties::set_parent (const octave_value& val) |
6705 | 2179 { |
2180 double tmp = val.double_value (); | |
6406 | 2181 |
6705 | 2182 graphics_handle new_parent = octave_NaN; |
6406 | 2183 |
6705 | 2184 if (! error_state) |
2185 { | |
2186 new_parent = gh_manager::lookup (tmp); | |
6406 | 2187 |
7056 | 2188 if (new_parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2189 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2190 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2191 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2192 parent_obj.remove_child (__myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2193 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2194 parent = new_parent.as_octave_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2195 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2196 ::adopt (parent.handle_value (), __myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2197 } |
6705 | 2198 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2199 error ("set: invalid graphics handle (= %g) for parent", tmp); |
6705 | 2200 } |
2201 else | |
2202 error ("set: expecting parent to be a graphics handle"); | |
2203 } | |
6432 | 2204 |
6705 | 2205 void |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2206 base_properties::set_children (const octave_value& val) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2207 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2208 const Matrix new_kids = val.matrix_value (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2209 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2210 octave_idx_type nel = new_kids.numel (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2211 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2212 const Matrix new_kids_column = new_kids.reshape (dim_vector (nel, 1)); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2213 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2214 bool ok = true; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2215 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2216 if (! error_state) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2217 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2218 const Matrix visible_kids = get_children (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2219 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2220 if (visible_kids.numel () == new_kids.numel ()) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2221 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2222 Matrix t1 = visible_kids.sort (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2223 Matrix t2 = new_kids_column.sort (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2224 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2225 if (t1 != t2) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2226 ok = false; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2227 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2228 else |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2229 ok = false; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2230 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2231 if (! ok) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2232 error ("set: new children must be a permutation of existing children"); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2233 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2234 else |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2235 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2236 ok = false; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2237 error ("set: expecting children to be array of graphics handles"); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2238 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2239 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2240 if (ok) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2241 children = new_kids_column.stack (get_hidden_children ()); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2242 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2243 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2244 void |
6836 | 2245 base_properties::mark_modified (void) |
2246 { | |
7363 | 2247 __modified__ = "on"; |
2248 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 2249 if (parent_obj) |
2250 parent_obj.mark_modified (); | |
6836 | 2251 } |
2252 | |
2253 void | |
2254 base_properties::override_defaults (base_graphics_object& obj) | |
2255 { | |
7363 | 2256 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2257 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2258 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2259 parent_obj.override_defaults (obj); |
6836 | 2260 } |
2261 | |
2262 void | |
7214 | 2263 base_properties::update_axis_limits (const std::string& axis_type) const |
2264 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2265 graphics_object obj = gh_manager::get_object (__myhandle__); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2266 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2267 if (obj) |
7214 | 2268 obj.update_axis_limits (axis_type); |
2269 } | |
2270 | |
2271 void | |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2272 base_properties::delete_children (void) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2273 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2274 octave_idx_type n = children.numel (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2275 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2276 // A callback function might have already deleted the child, |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2277 // so check before deleting |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2278 for (octave_idx_type i = 0; i < n; i++) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2279 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2280 graphics_object go = gh_manager::get_object (children(i)); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2281 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2282 if (go.valid_object ()) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2283 gh_manager::free (children(i)); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2284 } |
6836 | 2285 } |
2286 | |
7419 | 2287 graphics_backend |
2288 base_properties::get_backend (void) const | |
2289 { | |
2290 graphics_object go = gh_manager::get_object (get_parent ()); | |
2291 | |
2292 if (go) | |
2293 return go.get_backend (); | |
2294 else | |
2295 return graphics_backend (); | |
2296 } | |
2297 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2298 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2299 base_properties::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
|
2300 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2301 Matrix kids = get_children (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2302 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2303 for (int i = 0; i < kids.numel (); i++) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2304 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2305 graphics_object go = gh_manager::get_object (kids(i)); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2306 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2307 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2308 go.get_properties ().update_boundingbox (); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2309 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2310 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2311 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2312 void |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2313 base_properties::add_listener (const caseless_str& nm, const octave_value& v, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2314 listener_mode mode) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2315 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2316 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2317 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2318 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2319 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2320 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2321 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2322 void |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2323 base_properties::delete_listener (const caseless_str& nm, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2324 const octave_value& v, listener_mode mode) |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2325 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2326 property p = get_property (nm); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2327 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2328 if (! error_state && p.ok ()) |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2329 p.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
|
2330 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2331 |
7363 | 2332 // --------------------------------------------------------------------- |
2333 | |
7408 | 2334 class gnuplot_backend : public base_graphics_backend |
2335 { | |
2336 public: | |
2337 gnuplot_backend (void) | |
2338 : base_graphics_backend ("gnuplot") { } | |
2339 | |
2340 ~gnuplot_backend (void) { } | |
2341 | |
2342 bool is_valid (void) const { return true; } | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2343 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2344 void finalize (const graphics_object& go) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2345 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2346 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2347 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2348 const figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2349 dynamic_cast<const figure::properties&> (go.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2350 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2351 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2352 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2353 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2354 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2355 void update (const graphics_object& go, int id) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2356 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2357 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2358 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2359 graphics_object obj (go); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2360 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2361 figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2362 dynamic_cast<figure::properties&> (obj.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2363 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2364 switch (id) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2365 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2366 case base_properties::VISIBLE: |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2367 if (! props.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2368 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2369 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2370 props.set___plot_stream__ (Matrix ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2371 props.set___enhanced__ (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2372 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2373 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2374 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2375 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2376 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2377 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2378 void redraw_figure (const graphics_object& go) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2379 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2380 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2381 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2382 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2383 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2384 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2385 void print_figure (const graphics_object& go, const std::string& term, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2386 const std::string& file, bool mono, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2387 const std::string& debug_file) const |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2388 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2389 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2390 if (! debug_file.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2391 args(4) = debug_file; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2392 args(3) = mono; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2393 args(2) = file; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2394 args(1) = term; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2395 args(0) = go.get_handle ().as_octave_value (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2396 feval ("gnuplot_drawnow", args); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2397 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2398 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2399 Matrix get_canvas_size (const graphics_handle&) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2400 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2401 Matrix sz (1, 2, 0.0); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2402 return sz; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2403 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2404 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2405 double get_screen_resolution (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2406 { return 72.0; } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2407 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2408 Matrix get_screen_size (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2409 { return Matrix (1, 2, 0.0); } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2410 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2411 private: |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2412 void send_quit (const octave_value& pstream) const |
7408 | 2413 { |
9561
c60a9e1a0372
try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents:
9455
diff
changeset
|
2414 if (! pstream.is_empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2415 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2416 octave_value_list args; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2417 Matrix fids = pstream.matrix_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2418 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2419 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2420 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2421 args(1) = "\nquit;\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2422 args(0) = fids(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2423 feval ("fputs", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2424 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2425 args.resize (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2426 feval ("fflush", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2427 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2428 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2429 if (fids.numel () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2430 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2431 args(0) = fids(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2432 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2433 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2434 if (fids.numel () > 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2435 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2436 args(0) = fids(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2437 feval ("waitpid", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2438 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2439 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2440 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2441 } |
7408 | 2442 } |
2443 }; | |
2444 | |
2445 graphics_backend | |
2446 graphics_backend::default_backend (void) | |
2447 { | |
2448 if (available_backends.size () == 0) | |
2449 register_backend (new gnuplot_backend ()); | |
2450 | |
2451 return available_backends["gnuplot"]; | |
2452 } | |
2453 | |
2454 std::map<std::string, graphics_backend> graphics_backend::available_backends; | |
2455 | |
2456 // --------------------------------------------------------------------- | |
2457 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2458 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2459 base_graphics_object::update_axis_limits (const std::string& axis_type) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2460 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2461 if (valid_object ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2462 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2463 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2464 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2465 if (parent_obj) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2466 parent_obj.update_axis_limits (axis_type); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2467 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2468 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2469 error ("base_graphics_object::update_axis_limits: invalid graphics object"); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2470 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2471 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2472 void |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2473 base_graphics_object::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
|
2474 { |
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:
10995
diff
changeset
|
2475 octave_map m = get (true).map_value (); |
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:
10995
diff
changeset
|
2476 |
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:
10995
diff
changeset
|
2477 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++) |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2478 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2479 // FIXME -- there has to be a better way. I think we want to |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2480 // ask whether it is OK to delete the listener for the given |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2481 // property. How can we know in advance that it will be OK? |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2482 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2483 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2484 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2485 frame.protect_var (discard_error_messages); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2486 frame.protect_var (error_state); |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2487 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2488 discard_error_messages = true; |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2489 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2490 property p = get_properties ().get_property (pa->first); |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2491 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2492 if (! error_state && p.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2493 p.delete_listener (); |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2494 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2495 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2496 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2497 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2498 base_graphics_object::values_as_string (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2499 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2500 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2501 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2502 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2503 { |
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:
10995
diff
changeset
|
2504 octave_map m = get ().map_value (); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2505 |
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:
10995
diff
changeset
|
2506 for (octave_map::const_iterator pa = m.begin (); pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2507 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2508 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2509 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2510 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2511 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2512 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2513 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2514 retval += "\n\t" + std::string (pa->first) + ": "; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2515 if (p.is_radio ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2516 retval += p.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2517 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2518 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2519 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2520 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2521 retval += "\n"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2522 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2523 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2524 error ("base_graphics_object::values_as_string: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2525 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2526 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2527 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2528 |
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:
10995
diff
changeset
|
2529 octave_scalar_map |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2530 base_graphics_object::values_as_struct (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2531 { |
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:
10995
diff
changeset
|
2532 octave_scalar_map retval; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2533 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2534 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2535 { |
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:
10995
diff
changeset
|
2536 octave_scalar_map m = get ().scalar_map_value (); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2537 |
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:
10995
diff
changeset
|
2538 for (octave_scalar_map::const_iterator pa = m.begin (); |
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:
10995
diff
changeset
|
2539 pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2540 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2541 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2542 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2543 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2544 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2545 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2546 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2547 if (p.is_radio ()) |
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:
10995
diff
changeset
|
2548 retval.assign (p.get_name (), p.values_as_cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2549 else |
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:
10995
diff
changeset
|
2550 retval.assign (p.get_name (), Cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2551 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2552 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2553 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2554 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2555 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2556 error ("base_graphics_object::values_as_struct: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2557 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2558 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2559 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2560 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2561 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2562 |
7363 | 2563 #include "graphics-props.cc" |
2564 | |
2565 // --------------------------------------------------------------------- | |
2566 | |
6836 | 2567 void |
7363 | 2568 root_figure::properties::set_currentfigure (const octave_value& v) |
6874 | 2569 { |
7378 | 2570 graphics_handle val (v); |
7363 | 2571 |
6874 | 2572 if (error_state) |
2573 return; | |
2574 | |
7059 | 2575 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2576 { |
2577 currentfigure = val; | |
2578 | |
7363 | 2579 gh_manager::push_figure (val); |
6874 | 2580 } |
2581 else | |
2582 gripe_set_invalid ("currentfigure"); | |
2583 } | |
2584 | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2585 void |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2586 root_figure::properties::set_callbackobject (const octave_value& v) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2587 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2588 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2589 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2590 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2591 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2592 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2593 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2594 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2595 if (! cbo_stack.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2596 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2597 val = cbo_stack.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2598 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2599 cbo_stack.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2600 } |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2601 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2602 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2603 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2604 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2605 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2606 if (get_callbackobject ().ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2607 cbo_stack.push_front (get_callbackobject ()); |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2608 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2609 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2610 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2611 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2612 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2613 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2614 |
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
|
2615 // FIXME This should update monitorpositions and pointerlocation, but |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2616 // as these properties are yet used, and so it doesn't matter that they |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2617 // aren't set yet. |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2618 void |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2619 root_figure::properties::update_units (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2620 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2621 caseless_str xunits = get_units (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2622 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2623 Matrix ss = default_screensize (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2624 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2625 double dpi = get_screenpixelsperinch (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2626 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2627 if (xunits.compare ("inches")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2628 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2629 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2630 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2631 ss(2) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2632 ss(3) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2633 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2634 else if (xunits.compare ("centimeters")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2635 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2636 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2637 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2638 ss(2) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2639 ss(3) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2640 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2641 else if (xunits.compare ("normalized")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2642 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2643 ss = Matrix (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2644 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2645 else if (xunits.compare ("points")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2646 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2647 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2648 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2649 ss(2) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2650 ss(3) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2651 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2652 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2653 set_screensize (ss); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2654 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2655 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2656 void |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2657 root_figure::properties::remove_child (const graphics_handle& gh) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2658 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2659 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2660 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2661 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2662 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2663 xset (0, "currentfigure", cf.value ()); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2664 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2665 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2666 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2667 |
6406 | 2668 property_list |
2669 root_figure::factory_properties = root_figure::init_factory_properties (); | |
2670 | |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2671 static void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2672 reset_default_properties (property_list& default_properties) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2673 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2674 property_list new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2675 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2676 for (property_list::plist_map_const_iterator p = default_properties.begin (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2677 p != default_properties.end (); p++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2678 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2679 const property_list::pval_map_type pval_map = p->second; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2680 std::string prefix = p->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2681 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2682 for (property_list::pval_map_const_iterator q = pval_map.begin (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2683 q != pval_map.end (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2684 q++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2685 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2686 std::string s = q->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2687 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2688 if (prefix == "axes" && (s == "position" || s == "units")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2689 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2690 else if (prefix == "figure" && (s == "position" || s == "units" |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2691 || s == "windowstyle" |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2692 || s == "paperunits")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2693 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2694 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2695 } |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2696 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2697 default_properties = new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2698 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2699 |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2700 void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2701 root_figure::reset_default_properties (void) |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2702 { |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2703 ::reset_default_properties (default_properties); |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2704 } |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2705 |
6406 | 2706 // --------------------------------------------------------------------- |
2707 | |
7363 | 2708 void |
2709 figure::properties::set_currentaxes (const octave_value& v) | |
2710 { | |
7378 | 2711 graphics_handle val (v); |
6705 | 2712 |
6874 | 2713 if (error_state) |
2714 return; | |
2715 | |
7070 | 2716 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2717 currentaxes = val; |
2718 else | |
2719 gripe_set_invalid ("currentaxes"); | |
2720 } | |
2721 | |
2722 void | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2723 figure::properties::remove_child (const graphics_handle& gh) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2724 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2725 base_properties::remove_child (gh); |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2726 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2727 if (gh == currentaxes.handle_value ()) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2728 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2729 graphics_handle new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2730 |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2731 for (octave_idx_type i = 0; i < children.numel (); i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2732 { |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
2733 graphics_handle kid = children(i); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2734 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2735 graphics_object go = gh_manager::get_object (kid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2736 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2737 if (go.isa ("axes")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2738 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2739 new_currentaxes = kid; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2740 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2741 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2742 } |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2743 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2744 currentaxes = new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2745 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2746 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2747 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
2748 void |
6874 | 2749 figure::properties::set_visible (const octave_value& val) |
2750 { | |
2751 std::string s = val.string_value (); | |
2752 | |
2753 if (! error_state) | |
2754 { | |
2755 if (s == "on") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2756 xset (0, "currentfigure", __myhandle__.value ()); |
6874 | 2757 |
2758 visible = val; | |
2759 } | |
2760 } | |
2761 | |
7445 | 2762 Matrix |
7447 | 2763 figure::properties::get_boundingbox (bool) const |
7445 | 2764 { |
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
|
2765 Matrix screen_size = screen_size_pixels (); |
7445 | 2766 Matrix pos; |
2767 | |
10949
848f3a13b7cf
Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents:
10948
diff
changeset
|
2768 pos = convert_position (get_position ().matrix_value (), get_units (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2769 "pixels", screen_size); |
7445 | 2770 |
2771 pos(0)--; | |
2772 pos(1)--; | |
7447 | 2773 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 2774 |
2775 return pos; | |
2776 } | |
2777 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2778 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2779 figure::properties::set_boundingbox (const Matrix& bb) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2780 { |
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
|
2781 Matrix screen_size = screen_size_pixels (); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2782 Matrix pos = bb; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2783 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2784 pos(1) = screen_size(1) - pos(1) - pos(3); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2785 pos(1)++; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2786 pos(0)++; |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
2787 pos = convert_position (pos, "pixels", get_units (), screen_size); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2788 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2789 set_position (pos); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2790 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2791 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2792 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2793 figure::properties::set_position (const octave_value& v) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2794 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2795 if (! error_state) |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2796 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2797 Matrix old_bb, new_bb; |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2798 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2799 old_bb = get_boundingbox (); |
10949
848f3a13b7cf
Backed out changeset 6b50fd2d4ca6
David Bateman <dbateman@free.fr>
parents:
10948
diff
changeset
|
2800 position = v; |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2801 new_bb = get_boundingbox (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2802 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2803 if (old_bb != new_bb) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2804 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2805 if (old_bb(2) != new_bb(2) || old_bb(3) != new_bb(3)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2806 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2807 execute_resizefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2808 update_boundingbox (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2809 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2810 } |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2811 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2812 mark_modified (); |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2813 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2814 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2815 |
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
|
2816 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2817 figure::properties::set_paperunits (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2818 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2819 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2820 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2821 caseless_str typ = get_papertype (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2822 caseless_str punits = v.string_value (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2823 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2824 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
2825 if (punits.compare ("normalized") && typ.compare ("<custom>")) |
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
|
2826 error ("set: can't set the paperunits to normalized when the papertype is custom"); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2827 else |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2828 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2829 caseless_str old_paperunits = get_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
|
2830 if (paperunits.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2831 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2832 update_paperunits (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
|
2833 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2834 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2835 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2836 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2837 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2838 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2839 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2840 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2841 figure::properties::set_papertype (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2842 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2843 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2844 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2845 caseless_str typ = v.string_value (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2846 caseless_str punits = get_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
|
2847 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2848 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
2849 if (punits.compare ("normalized") && typ.compare ("<custom>")) |
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
|
2850 error ("set: can't set the paperunits to normalized when the papertype is custom"); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2851 else |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2852 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2853 if (papertype.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2854 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2855 update_papertype (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2856 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2857 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2858 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2859 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2860 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2861 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2862 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2863 static Matrix |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2864 papersize_from_type (const caseless_str punits, const caseless_str typ) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2865 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2866 Matrix ret (1, 2, 1.0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2867 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2868 if (! punits.compare ("normalized")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2869 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2870 double in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2871 double mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2872 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2873 if (punits.compare ("inches")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2874 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2875 in2units = 1.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2876 mm2units = 1 / 25.4 ; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2877 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2878 else if (punits.compare ("centimeters")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2879 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2880 in2units = 2.54; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2881 mm2units = 1 / 10.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2882 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2883 else // points |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2884 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2885 in2units = 72.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2886 mm2units = 72.0 / 25.4; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2887 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2888 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2889 if (typ.compare ("usletter")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2890 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2891 ret (0) = 8.5 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2892 ret (1) = 11.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2893 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2894 else if (typ.compare ("uslegal")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2895 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2896 ret (0) = 8.5 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2897 ret (1) = 14.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2898 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2899 else if (typ.compare ("tabloid")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2900 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2901 ret (0) = 11.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2902 ret (1) = 17.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2903 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2904 else if (typ.compare ("a0")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2905 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2906 ret (0) = 841.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2907 ret (1) = 1189.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2908 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2909 else if (typ.compare ("a1")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2910 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2911 ret (0) = 594.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2912 ret (1) = 841.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2913 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2914 else if (typ.compare ("a2")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2915 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2916 ret (0) = 420.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2917 ret (1) = 594.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2918 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2919 else if (typ.compare ("a3")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2920 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2921 ret (0) = 297.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2922 ret (1) = 420.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2923 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2924 else if (typ.compare ("a4")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2925 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2926 ret (0) = 210.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2927 ret (1) = 297.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2928 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2929 else if (typ.compare ("a5")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2930 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2931 ret (0) = 148.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2932 ret (1) = 210.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2933 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2934 else if (typ.compare ("b0")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2935 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2936 ret (0) = 1029.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2937 ret (1) = 1456.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2938 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2939 else if (typ.compare ("b1")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2940 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2941 ret (0) = 728.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2942 ret (1) = 1028.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2943 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2944 else if (typ.compare ("b2")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2945 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2946 ret (0) = 514.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2947 ret (1) = 728.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2948 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2949 else if (typ.compare ("b3")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2950 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2951 ret (0) = 364.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2952 ret (1) = 514.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2953 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2954 else if (typ.compare ("b4")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2955 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2956 ret (0) = 257.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2957 ret (1) = 364.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2958 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2959 else if (typ.compare ("b5")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2960 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2961 ret (0) = 182.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2962 ret (1) = 257.0 * mm2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2963 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2964 else if (typ.compare ("arch-a")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2965 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2966 ret (0) = 9.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2967 ret (1) = 12.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2968 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2969 else if (typ.compare ("arch-b")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2970 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2971 ret (0) = 12.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2972 ret (1) = 18.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2973 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2974 else if (typ.compare ("arch-c")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2975 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2976 ret (0) = 18.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2977 ret (1) = 24.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2978 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2979 else if (typ.compare ("arch-d")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2980 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2981 ret (0) = 24.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2982 ret (1) = 36.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2983 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2984 else if (typ.compare ("arch-e")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2985 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2986 ret (0) = 36.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2987 ret (1) = 48.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2988 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2989 else if (typ.compare ("a")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2990 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2991 ret (0) = 8.5 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2992 ret (1) = 11.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2993 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2994 else if (typ.compare ("b")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2995 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2996 ret (0) = 11.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2997 ret (1) = 17.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2998 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
2999 else if (typ.compare ("c")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3000 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3001 ret (0) = 17.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3002 ret (1) = 22.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3003 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3004 else if (typ.compare ("d")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3005 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3006 ret (0) = 22.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3007 ret (1) = 34.0 * in2units; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3008 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3009 else if (typ.compare ("e")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3010 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3011 ret (0) = 34.0 * in2units; |
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 ret (1) = 43.0 * in2units; |
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 } |
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 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3016 return ret; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3017 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3018 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3019 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3020 figure::properties::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
|
3021 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3022 Matrix pos = get_paperposition ().matrix_value (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3023 Matrix sz = get_papersize ().matrix_value (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3024 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3025 pos (0) = pos (0) / sz(0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3026 pos (1) = pos (1) / sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3027 pos (2) = pos (2) / sz(0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3028 pos (3) = pos (3) / sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3029 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3030 caseless_str punits = get_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
|
3031 caseless_str typ = get_papertype (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3032 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3033 if (typ.compare ("<custom>")) |
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
|
3034 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3035 if (old_paperunits.compare ("centimeters")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3036 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3037 sz (0) = sz (0) / 2.54; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3038 sz (1) = sz (1) / 2.54; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3039 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3040 else if (old_paperunits.compare ("points")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3041 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3042 sz (0) = sz (0) / 72.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3043 sz (1) = sz (1) / 72.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3044 } |
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 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3046 if (punits.compare ("centimeters")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3047 { |
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 sz(0) = sz(0) * 2.54; |
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 sz(1) = sz(1) * 2.54; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3050 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3051 else if (old_paperunits.compare ("points")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3052 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3053 sz (0) = sz (0) * 72.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3054 sz (1) = sz (1) * 72.0; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3055 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3056 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3057 else |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3058 sz = papersize_from_type (punits, typ); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3059 |
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 pos (0) = pos (0) * sz(0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3061 pos (1) = pos (1) * sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3062 pos (2) = pos (2) * sz(0); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3063 pos (3) = pos (3) * sz(1); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3064 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3065 papersize.set (octave_value (sz)); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3066 paperposition.set (octave_value (pos)); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3067 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3068 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3069 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3070 figure::properties::update_papertype (void) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3071 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3072 caseless_str typ = get_papertype (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3073 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3074 if (! typ.compare ("<custom>")) |
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
|
3075 // Call papersize.set rather than set_papersize to avoid loops between |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3076 // update_papersize and update_papertype |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3077 papersize.set (octave_value (papersize_from_type (get_paperunits (), typ))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3078 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3079 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3080 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3081 figure::properties::update_papersize (void) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3082 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3083 papertype.set ("<custom>"); |
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
|
3084 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3085 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3086 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3087 figure::properties::set_units (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3088 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3089 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3090 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3091 caseless_str old_units = get_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
|
3092 if (units.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3093 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3094 update_units (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
|
3095 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3096 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3097 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3098 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3099 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3100 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3101 figure::properties::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
|
3102 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3103 set_position (convert_position (get_position ().matrix_value (), 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
|
3104 get_units (), screen_size_pixels ())); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3105 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3106 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3107 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3108 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3109 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3110 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3111 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3112 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
3113 std::string nm = get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3114 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3115 os << "Figure " << __myhandle__.value (); |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
3116 if (! nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3117 os << ": " << get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3118 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3119 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3120 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3121 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3122 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3123 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3124 |
6836 | 3125 octave_value |
7189 | 3126 figure::get_default (const caseless_str& name) const |
6836 | 3127 { |
3128 octave_value retval = default_properties.lookup (name); | |
3129 | |
3130 if (retval.is_undefined ()) | |
3131 { | |
3132 graphics_handle parent = get_parent (); | |
3133 graphics_object parent_obj = gh_manager::get_object (parent); | |
3134 | |
3135 retval = parent_obj.get_default (name); | |
3136 } | |
3137 | |
3138 return retval; | |
3139 } | |
3140 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3141 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3142 figure::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3143 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3144 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3145 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3146 |
6406 | 3147 // --------------------------------------------------------------------- |
3148 | |
8249 | 3149 void |
3150 axes::properties::init (void) | |
3151 { | |
3152 position.add_constraint (dim_vector (1, 4)); | |
3153 position.add_constraint (dim_vector (0, 0)); | |
3154 outerposition.add_constraint (dim_vector (1, 4)); | |
3155 colororder.add_constraint (dim_vector (-1, 3)); | |
3156 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
3157 plotboxaspectratio.add_constraint (dim_vector (1, 3)); | |
3158 xlim.add_constraint (2); | |
3159 ylim.add_constraint (2); | |
3160 zlim.add_constraint (2); | |
3161 clim.add_constraint (2); | |
3162 alim.add_constraint (2); | |
3163 xtick.add_constraint (dim_vector (1, -1)); | |
3164 ytick.add_constraint (dim_vector (1, -1)); | |
3165 ztick.add_constraint (dim_vector (1, -1)); | |
3166 Matrix vw (1, 2, 0); | |
3167 vw(1) = 90; | |
3168 view = vw; | |
3169 view.add_constraint (dim_vector (1, 2)); | |
3170 cameraposition.add_constraint (dim_vector (1, 3)); | |
3171 Matrix upv (1, 3, 0.0); | |
3172 upv(2) = 1.0; | |
3173 cameraupvector = upv; | |
3174 cameraupvector.add_constraint (dim_vector (1, 3)); | |
3175 currentpoint.add_constraint (dim_vector (2, 3)); | |
3176 ticklength.add_constraint (dim_vector (1, 2)); | |
3177 tightinset.add_constraint (dim_vector (1, 4)); | |
3178 | |
3179 x_zlim.resize (1, 2); | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3180 |
8249 | 3181 sx = "linear"; |
3182 sy = "linear"; | |
3183 sz = "linear"; | |
3184 | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3185 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3186 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3187 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3188 |
8249 | 3189 xset (xlabel.handle_value (), "handlevisibility", "off"); |
3190 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3191 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3192 xset (title.handle_value (), "handlevisibility", "off"); | |
3193 | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3194 xset (xlabel.handle_value (), "horizontalalignment", "center"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3195 xset (ylabel.handle_value (), "horizontalalignment", "center"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3196 xset (zlabel.handle_value (), "horizontalalignment", "right"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3197 xset (title.handle_value (), "horizontalalignment", "center"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3198 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3199 xset (xlabel.handle_value (), "verticalalignment", "cap"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3200 xset (ylabel.handle_value (), "verticalalignment", "bottom"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3201 xset (title.handle_value (), "verticalalignment", "bottom"); |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3202 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3203 xset (ylabel.handle_value (), "rotation", 90.0); |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3204 xset (zlabel.handle_value (), "visible", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3205 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3206 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3207 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3208 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3209 xset (title.handle_value (), "clipping", "off"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3210 |
8249 | 3211 adopt (xlabel.handle_value ()); |
3212 adopt (ylabel.handle_value ()); | |
3213 adopt (zlabel.handle_value ()); | |
3214 adopt (title.handle_value ()); | |
3215 } | |
3216 | |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3217 void |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3218 axes::properties::sync_positions (void) |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3219 { |
8208 | 3220 #if 0 |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3221 // FIXME -- this should take font metrics into consideration, |
8208 | 3222 // and also the fact that the colorbox leaves the outerposition |
3223 // alone but alters the position. For now just don't adjust the | |
3224 // positions relative to each other. | |
3225 | |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3226 if (activepositionproperty.is ("outerposition")) |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3227 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3228 Matrix outpos = outerposition.get ().matrix_value (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3229 Matrix defpos = default_axes_position (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3230 Matrix pos(outpos); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3231 pos(0) = outpos(0) + defpos(0) * outpos(2); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3232 pos(1) = outpos(1) + defpos(1) * outpos(3); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3233 pos(2) = outpos(2) * defpos(2); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3234 pos(3) = outpos(3) * defpos(3); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3235 position = pos; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3236 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3237 else |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3238 { |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3239 Matrix pos = position.get ().matrix_value (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3240 pos(0) -= pos(2)*0.05; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3241 pos(1) -= pos(3)*0.05; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3242 pos(2) *= 1.1; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3243 pos(3) *= 1.1; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3244 outerposition = pos; |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3245 } |
8208 | 3246 #endif |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3247 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3248 update_transform (); |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3249 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3250 |
7363 | 3251 void |
8249 | 3252 axes::properties::set_text_child (handle_property& hp, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3253 const std::string& who, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3254 const octave_value& v) |
6962 | 3255 { |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3256 graphics_handle val; |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3257 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3258 if (v.is_string ()) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3259 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3260 val = gh_manager::make_graphics_handle ("text", __myhandle__, false); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3261 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3262 xset (val, "string", v); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3263 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3264 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3265 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3266 graphics_object go = gh_manager::get_object (gh_manager::lookup (v)); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3267 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3268 if (go.isa ("text")) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3269 val = ::reparent (v, "set", who, __myhandle__, false); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3270 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3271 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3272 std::string cname = v.class_name (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3273 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3274 error ("set: expecting text graphics object or character string for %s property, found %s", |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3275 who.c_str (), cname.c_str ()); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3276 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3277 } |
6962 | 3278 |
6874 | 3279 if (! error_state) |
3280 { | |
8249 | 3281 xset (val, "handlevisibility", "off"); |
3282 | |
3283 gh_manager::free (hp.handle_value ()); | |
3284 | |
3285 base_properties::remove_child (hp.handle_value ()); | |
3286 | |
3287 hp = val; | |
3288 | |
3289 adopt (hp.handle_value ()); | |
6874 | 3290 } |
3291 } | |
3292 | |
3293 void | |
7363 | 3294 axes::properties::set_xlabel (const octave_value& v) |
6874 | 3295 { |
8249 | 3296 set_text_child (xlabel, "xlabel", v); |
6874 | 3297 } |
3298 | |
3299 void | |
7363 | 3300 axes::properties::set_ylabel (const octave_value& v) |
6874 | 3301 { |
8249 | 3302 set_text_child (ylabel, "ylabel", v); |
6874 | 3303 } |
3304 | |
3305 void | |
7363 | 3306 axes::properties::set_zlabel (const octave_value& v) |
6874 | 3307 { |
8249 | 3308 set_text_child (zlabel, "zlabel", v); |
3309 } | |
3310 | |
3311 void | |
3312 axes::properties::set_title (const octave_value& v) | |
3313 { | |
3314 set_text_child (title, "title", v); | |
6874 | 3315 } |
3316 | |
3317 void | |
6844 | 3318 axes::properties::set_defaults (base_graphics_object& obj, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3319 const std::string& mode) |
6705 | 3320 { |
3321 box = "on"; | |
6962 | 3322 colororder = default_colororder (); |
6705 | 3323 dataaspectratio = Matrix (1, 3, 1.0); |
3324 dataaspectratiomode = "auto"; | |
7363 | 3325 layer = "bottom"; |
6705 | 3326 |
3327 Matrix tlim (1, 2, 0.0); | |
3328 tlim(1) = 1; | |
3329 xlim = tlim; | |
3330 ylim = tlim; | |
3331 zlim = tlim; | |
6807 | 3332 |
3333 Matrix cl (1, 2, 0); | |
3334 cl(1) = 1; | |
3335 clim = cl; | |
3336 | |
7363 | 3337 xlimmode = "auto"; |
3338 ylimmode = "auto"; | |
3339 zlimmode = "auto"; | |
3340 climmode = "auto"; | |
8208 | 3341 |
6705 | 3342 xgrid = "off"; |
3343 ygrid = "off"; | |
3344 zgrid = "off"; | |
3345 xminorgrid = "off"; | |
3346 yminorgrid = "off"; | |
3347 zminorgrid = "off"; | |
3348 xtick = Matrix (); | |
3349 ytick = Matrix (); | |
3350 ztick = Matrix (); | |
3351 xtickmode = "auto"; | |
3352 ytickmode = "auto"; | |
3353 ztickmode = "auto"; | |
3354 xticklabel = ""; | |
3355 yticklabel = ""; | |
3356 zticklabel = ""; | |
3357 xticklabelmode = "auto"; | |
3358 yticklabelmode = "auto"; | |
3359 zticklabelmode = "auto"; | |
10565
2880a862b1a8
Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents:
10553
diff
changeset
|
3360 color = "none"; |
7364 | 3361 xcolor = color_values ("black"); |
3362 ycolor = color_values ("black"); | |
3363 zcolor = color_values ("black"); | |
7363 | 3364 xscale = "linear"; |
3365 yscale = "linear"; | |
3366 zscale = "linear"; | |
6705 | 3367 xdir = "normal"; |
3368 ydir = "normal"; | |
3369 zdir = "normal"; | |
7363 | 3370 yaxislocation = "left"; |
3371 xaxislocation = "bottom"; | |
6705 | 3372 |
7427 | 3373 // Note: camera properties will be set through update_transform |
3374 camerapositionmode = "auto"; | |
3375 cameratargetmode = "auto"; | |
3376 cameraupvectormode = "auto"; | |
3377 cameraviewanglemode = "auto"; | |
3378 plotboxaspectratio = Matrix (1, 3, 1.0); | |
3379 drawmode = "normal"; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
3380 gridlinestyle = ":"; |
7427 | 3381 linestyleorder = "-"; |
3382 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
3383 minorgridlinestyle = ":"; |
7427 | 3384 // Note: plotboxaspectratio will be set through update_aspectratiors |
3385 plotboxaspectratiomode = "auto"; | |
3386 projection = "orthographic"; | |
3387 tickdir = "in"; | |
3388 tickdirmode = "auto"; | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
3389 ticklength = default_axes_ticklength (); |
7427 | 3390 tightinset = Matrix (1, 4, 0.0); |
3391 | |
3392 sx = "linear"; | |
3393 sy = "linear"; | |
3394 sz = "linear"; | |
3395 | |
6705 | 3396 Matrix tview (1, 2, 0.0); |
3397 tview(1) = 90; | |
3398 view = tview; | |
3399 | |
6765 | 3400 visible = "on"; |
6705 | 3401 nextplot = "replace"; |
3402 | |
3403 if (mode != "replace") | |
3404 { | |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3405 fontangle = "normal"; |
8944
cb0e9facc342
make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
3406 fontname = OCTAVE_DEFAULT_FONTNAME; |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3407 fontsize = 12; |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3408 fontunits = "points"; |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3409 fontweight = "normal"; |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3410 |
6406 | 3411 Matrix touterposition (1, 4, 0.0); |
3412 touterposition(2) = 1; | |
3413 touterposition(3) = 1; | |
3414 outerposition = touterposition; | |
7860
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3415 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3416 position = default_axes_position (); |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3417 |
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
3418 activepositionproperty = "outerposition"; |
6406 | 3419 } |
3420 | |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3421 delete_children (); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3422 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3423 children = Matrix (); |
6432 | 3424 |
8249 | 3425 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); |
3426 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3427 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3428 title = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3429 | |
3430 xset (xlabel.handle_value (), "handlevisibility", "off"); | |
3431 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3432 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3433 xset (title.handle_value (), "handlevisibility", "off"); | |
3434 | |
8636 | 3435 xset (xlabel.handle_value (), "horizontalalignment", "center"); |
3436 xset (ylabel.handle_value (), "horizontalalignment", "center"); | |
3437 xset (zlabel.handle_value (), "horizontalalignment", "right"); | |
3438 xset (title.handle_value (), "horizontalalignment", "center"); | |
3439 | |
3440 xset (xlabel.handle_value (), "verticalalignment", "cap"); | |
3441 xset (ylabel.handle_value (), "verticalalignment", "bottom"); | |
3442 xset (title.handle_value (), "verticalalignment", "bottom"); | |
3443 | |
3444 xset (ylabel.handle_value (), "rotation", 90.0); | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3445 xset (zlabel.handle_value (), "visible", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3446 |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3447 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3448 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3449 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3450 xset (title.handle_value (), "clipping", "off"); |
8636 | 3451 |
8249 | 3452 adopt (xlabel.handle_value ()); |
3453 adopt (ylabel.handle_value ()); | |
3454 adopt (zlabel.handle_value ()); | |
3455 adopt (title.handle_value ()); | |
3456 | |
7427 | 3457 update_transform (); |
3458 | |
6705 | 3459 override_defaults (obj); |
3460 } | |
3461 | |
8208 | 3462 void |
3463 axes::properties::delete_text_child (handle_property& hp) | |
6874 | 3464 { |
8208 | 3465 graphics_handle h = hp.handle_value (); |
3466 | |
3467 if (h.ok ()) | |
3468 { | |
3469 graphics_object go = gh_manager::get_object (h); | |
3470 | |
3471 if (go.valid_object ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3472 gh_manager::free (h); |
8249 | 3473 |
3474 base_properties::remove_child (h); | |
8208 | 3475 } |
3476 | |
8249 | 3477 // FIXME -- is it necessary to check whether the axes object is |
3478 // being deleted now? I think this function is only called when an | |
3479 // individual child object is delete and not when the parent axes | |
3480 // object is deleted. | |
3481 | |
8208 | 3482 if (! is_beingdeleted ()) |
8249 | 3483 { |
3484 hp = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
3485 | |
3486 xset (hp.handle_value (), "handlevisibility", "off"); | |
3487 | |
3488 adopt (hp.handle_value ()); | |
3489 } | |
6705 | 3490 } |
6406 | 3491 |
6705 | 3492 void |
6844 | 3493 axes::properties::remove_child (const graphics_handle& h) |
6705 | 3494 { |
8249 | 3495 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
8208 | 3496 delete_text_child (xlabel); |
7363 | 3497 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
8208 | 3498 delete_text_child (ylabel); |
7363 | 3499 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
8208 | 3500 delete_text_child (zlabel); |
8249 | 3501 else if (title.handle_value ().ok () && h == title.handle_value ()) |
3502 delete_text_child (title); | |
6705 | 3503 else |
3504 base_properties::remove_child (h); | |
3505 } | |
6406 | 3506 |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3507 Matrix |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3508 base_properties::get_children_internal (bool return_hidden) const |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3509 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3510 Matrix retval = children; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3511 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3512 graphics_object go = gh_manager::get_object (0); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3513 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3514 root_figure::properties& props = |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3515 dynamic_cast<root_figure::properties&> (go.get_properties ()); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3516 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3517 if (! props.is_showhiddenhandles ()) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3518 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3519 octave_idx_type k = 0; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3520 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3521 for (octave_idx_type i = 0; i < children.numel (); i++) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3522 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3523 graphics_handle kid = children (i); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3524 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3525 if (gh_manager::is_handle_visible (kid)) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3526 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3527 if (! return_hidden) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3528 retval(k++) = children(i); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3529 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3530 else |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3531 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3532 if (return_hidden) |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3533 retval(k++) = children(i); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3534 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3535 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3536 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3537 retval.resize (k, 1); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3538 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3539 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3540 return retval; |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3541 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3542 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3543 Matrix |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3544 base_properties::get_children (void) const |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3545 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3546 return get_children_internal (false); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3547 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3548 |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3549 Matrix |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3550 base_properties::get_hidden_children (void) const |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3551 { |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3552 return get_children_internal (true); |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3553 } |
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
3554 |
7427 | 3555 inline Matrix |
3556 xform_matrix (void) | |
3557 { | |
3558 Matrix m (4, 4, 0.0); | |
3559 for (int i = 0; i < 4; i++) | |
3560 m(i,i) = 1; | |
3561 return m; | |
3562 } | |
3563 | |
3564 inline ColumnVector | |
3565 xform_vector (void) | |
3566 { | |
3567 ColumnVector v (4, 0.0); | |
3568 v(3) = 1; | |
3569 return v; | |
3570 } | |
3571 | |
3572 inline ColumnVector | |
3573 xform_vector (double x, double y, double z) | |
3574 { | |
3575 ColumnVector v (4, 1.0); | |
3576 v(0) = x; v(1) = y; v(2) = z; | |
3577 return v; | |
3578 } | |
3579 | |
3580 inline ColumnVector | |
3581 transform (const Matrix& m, double x, double y, double z) | |
3582 { | |
3583 return (m * xform_vector (x, y, z)); | |
3584 } | |
3585 | |
3586 inline Matrix | |
3587 xform_scale (double x, double y, double z) | |
3588 { | |
3589 Matrix m (4, 4, 0.0); | |
3590 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
3591 return m; | |
3592 } | |
3593 | |
3594 inline Matrix | |
3595 xform_translate (double x, double y, double z) | |
3596 { | |
3597 Matrix m = xform_matrix (); | |
3598 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
3599 return m; | |
3600 } | |
3601 | |
3602 inline void | |
3603 scale (Matrix& m, double x, double y, double z) | |
3604 { | |
3605 m = m * xform_scale (x, y, z); | |
3606 } | |
3607 | |
3608 inline void | |
3609 translate (Matrix& m, double x, double y, double z) | |
3610 { | |
3611 m = m * xform_translate (x, y, z); | |
3612 } | |
3613 | |
3614 inline void | |
3615 xform (ColumnVector& v, const Matrix& m) | |
3616 { | |
3617 v = m*v; | |
3618 } | |
3619 | |
3620 inline void | |
3621 scale (ColumnVector& v, double x, double y, double z) | |
3622 { | |
3623 v(0) *= x; | |
3624 v(1) *= y; | |
3625 v(2) *= z; | |
3626 } | |
3627 | |
3628 inline void | |
3629 translate (ColumnVector& v, double x, double y, double z) | |
3630 { | |
3631 v(0) += x; | |
3632 v(1) += y; | |
3633 v(2) += z; | |
3634 } | |
3635 | |
3636 inline void | |
3637 normalize (ColumnVector& v) | |
3638 { | |
3639 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); | |
3640 scale (v, fact, fact, fact); | |
3641 } | |
3642 | |
3643 inline double | |
3644 dot (const ColumnVector& v1, const ColumnVector& v2) | |
3645 { | |
3646 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
3647 } | |
3648 | |
3649 inline double | |
3650 norm (const ColumnVector& v) | |
3651 { | |
3652 return sqrt (dot (v, v)); | |
3653 } | |
3654 | |
3655 inline ColumnVector | |
3656 cross (const ColumnVector& v1, const ColumnVector& v2) | |
3657 { | |
3658 ColumnVector r = xform_vector (); | |
3659 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
3660 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
3661 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
3662 return r; | |
3663 } | |
3664 | |
3665 inline Matrix | |
3666 unit_cube (void) | |
3667 { | |
3668 static double data[32] = { | |
3669 0,0,0,1, | |
3670 1,0,0,1, | |
3671 0,1,0,1, | |
3672 0,0,1,1, | |
3673 1,1,0,1, | |
3674 1,0,1,1, | |
3675 0,1,1,1, | |
3676 1,1,1,1}; | |
3677 Matrix m (4, 8); | |
3678 memcpy (m.fortran_vec (), data, sizeof(double)*32); | |
3679 return m; | |
3680 } | |
3681 | |
3682 inline ColumnVector | |
3683 cam2xform (const Array<double>& m) | |
3684 { | |
3685 ColumnVector retval (4, 1.0); | |
3686 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); | |
3687 return retval; | |
3688 } | |
3689 | |
3690 inline RowVector | |
3691 xform2cam (const ColumnVector& v) | |
3692 { | |
3693 return v.extract_n (0, 3).transpose (); | |
3694 } | |
3695 | |
3696 void | |
3697 axes::properties::update_camera (void) | |
3698 { | |
3699 double xd = (xdir_is ("normal") ? 1 : -1); | |
3700 double yd = (ydir_is ("normal") ? 1 : -1); | |
3701 double zd = (zdir_is ("normal") ? 1 : -1); | |
3702 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3703 Matrix xlimits = sx.scale (get_xlim ().matrix_value ()); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3704 Matrix ylimits = sy.scale (get_ylim ().matrix_value ()); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3705 Matrix zlimits = sz.scale (get_zlim ().matrix_value ()); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3706 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3707 double xo = xlimits(xd > 0 ? 0 : 1); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3708 double yo = ylimits(yd > 0 ? 0 : 1); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3709 double zo = zlimits(zd > 0 ? 0 : 1); |
7427 | 3710 |
3711 Matrix pb = get_plotboxaspectratio ().matrix_value (); | |
3712 | |
3713 bool autocam = (camerapositionmode_is ("auto") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3714 && cameratargetmode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3715 && cameraupvectormode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3716 && cameraviewanglemode_is ("auto")); |
7427 | 3717 bool dowarp = (autocam && dataaspectratiomode_is("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3718 && plotboxaspectratiomode_is ("auto")); |
7427 | 3719 |
3720 ColumnVector c_eye (xform_vector ()); | |
3721 ColumnVector c_center (xform_vector ()); | |
3722 ColumnVector c_upv (xform_vector ()); | |
3723 | |
3724 if (cameratargetmode_is ("auto")) | |
3725 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3726 c_center(0) = (xlimits(0)+xlimits(1))/2; |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3727 c_center(1) = (ylimits(0)+ylimits(1))/2; |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3728 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 3729 |
3730 cameratarget = xform2cam (c_center); | |
3731 } | |
3732 else | |
3733 c_center = cam2xform (get_cameratarget ().matrix_value ()); | |
3734 | |
3735 if (camerapositionmode_is ("auto")) | |
3736 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3737 Matrix tview = get_view ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3738 double az = tview(0), el = tview(1); |
7427 | 3739 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
3740 | |
3741 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3742 c_eye(2) = d*signum(el); |
7427 | 3743 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3744 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3745 az *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3746 el *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3747 c_eye(0) = d*cos(el)*sin(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3748 c_eye(1) = -d*cos(el)*cos(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3749 c_eye(2) = d*sin(el); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3750 } |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3751 c_eye(0) = c_eye(0)*(xlimits(1)-xlimits(0))/(xd*pb(0))+c_center(0); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3752 c_eye(1) = c_eye(1)*(ylimits(1)-ylimits(0))/(yd*pb(1))+c_center(1); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3753 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 3754 |
3755 cameraposition = xform2cam (c_eye); | |
3756 } | |
3757 else | |
3758 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
3759 | |
3760 if (cameraupvectormode_is ("auto")) | |
3761 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3762 Matrix tview = get_view ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3763 double az = tview(0), el = tview(1); |
7427 | 3764 |
3765 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3766 { |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3767 c_upv(0) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3768 -signum(el)*sin(az*M_PI/180.0)*(xlimits(1)-xlimits(0))/pb(0); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3769 c_upv(1) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
3770 signum(el)*cos(az*M_PI/180.0)*(ylimits(1)-ylimits(0))/pb(1); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3771 } |
7427 | 3772 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3773 c_upv(2) = 1; |
7427 | 3774 |
3775 cameraupvector = xform2cam (c_upv); | |
3776 } | |
3777 else | |
3778 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
3779 | |
3780 Matrix x_view = xform_matrix (); | |
3781 Matrix x_projection = xform_matrix (); | |
3782 Matrix x_viewport = xform_matrix (); | |
3783 Matrix x_normrender = xform_matrix (); | |
3784 Matrix x_pre = xform_matrix (); | |
3785 | |
3786 x_render = xform_matrix (); | |
3787 x_render_inv = xform_matrix (); | |
3788 | |
3789 scale (x_pre, pb(0), pb(1), pb(2)); | |
3790 translate (x_pre, -0.5, -0.5, -0.5); | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3791 scale (x_pre, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3792 zd/(zlimits(1)-zlimits(0))); |
7427 | 3793 translate (x_pre, -xo, -yo, -zo); |
3794 | |
3795 xform (c_eye, x_pre); | |
3796 xform (c_center, x_pre); | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3797 scale (c_upv, pb(0)/(xlimits(1)-xlimits(0)), pb(1)/(ylimits(1)-ylimits(0)), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3798 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 3799 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
3800 | |
3801 ColumnVector F (c_center), f (F), UP (c_upv); | |
3802 normalize (f); | |
3803 normalize (UP); | |
3804 | |
7440 | 3805 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 3806 { |
3807 double fa = 1/sqrt(1-f(2)*f(2)); | |
3808 scale (UP, fa, fa, fa); | |
3809 } | |
3810 | |
3811 ColumnVector s = cross (f, UP); | |
3812 ColumnVector u = cross (s, f); | |
3813 | |
3814 scale (x_view, 1, 1, -1); | |
3815 Matrix l = xform_matrix (); | |
3816 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
3817 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
3818 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
3819 x_view = x_view * l; | |
3820 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
3821 scale (x_view, pb(0), pb(1), pb(2)); | |
3822 translate (x_view, -0.5, -0.5, -0.5); | |
3823 | |
3824 Matrix x_cube = x_view * unit_cube (); | |
3825 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max (); | |
3826 double xM = cmax(0)-cmin(0); | |
3827 double yM = cmax(1)-cmin(1); | |
3828 | |
7447 | 3829 Matrix bb = get_boundingbox (true); |
7427 | 3830 |
3831 double v_angle; | |
3832 | |
3833 if (cameraviewanglemode_is ("auto")) | |
3834 { | |
3835 double af; | |
3836 | |
8333 | 3837 // FIXME -- was this really needed? When compared to Matlab, it |
7427 | 3838 // does not seem to be required. Need investigation with concrete |
3839 // backend to see results visually. | |
3840 if (false && dowarp) | |
3841 af = 1.0 / (xM > yM ? xM : yM); | |
3842 else | |
3843 { | |
3844 if ((bb(2)/bb(3)) > (xM/yM)) | |
3845 af = 1.0 / yM; | |
3846 else | |
3847 af = 1.0 / xM; | |
3848 } | |
3849 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
3850 | |
3851 cameraviewangle = v_angle; | |
3852 } | |
3853 else | |
3854 v_angle = get_cameraviewangle (); | |
3855 | |
3856 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
3857 scale (x_projection, pf, pf, 1); | |
3858 | |
3859 if (dowarp) | |
3860 { | |
3861 xM *= pf; | |
3862 yM *= pf; | |
7447 | 3863 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 3864 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
3865 } | |
3866 else | |
3867 { | |
3868 double pix = 1; | |
3869 if (autocam) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3870 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3871 if ((bb(2)/bb(3)) > (xM/yM)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3872 pix = bb(3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3873 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3874 pix = bb(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3875 } |
7427 | 3876 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3877 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); |
7447 | 3878 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 3879 scale (x_viewport, pix, -pix, 1); |
3880 } | |
3881 | |
3882 x_normrender = x_viewport * x_projection * x_view; | |
3883 | |
3884 x_cube = x_normrender * unit_cube (); | |
3885 cmin = x_cube.row_min (); | |
3886 cmax = x_cube.row_max (); | |
3887 x_zlim.resize (1, 2); | |
3888 x_zlim(0) = cmin(2); | |
3889 x_zlim(1) = cmax(2); | |
3890 | |
3891 x_render = x_normrender; | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3892 scale (x_render, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3893 zd/(zlimits(1)-zlimits(0))); |
7427 | 3894 translate (x_render, -xo, -yo, -zo); |
3895 | |
3896 x_viewtransform = x_view; | |
3897 x_projectiontransform = x_projection; | |
3898 x_viewporttransform = x_viewport; | |
3899 x_normrendertransform = x_normrender; | |
3900 x_rendertransform = x_render; | |
3901 | |
3902 x_render_inv = x_render.inverse (); | |
3903 | |
3904 // Note: these matrices are a slight modified version of the regular | |
3905 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
3906 // => x_gl_mat2) | |
3907 x_gl_mat1 = x_view; | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3908 scale (x_gl_mat1, xd/(xlimits(1)-xlimits(0)), yd/(ylimits(1)-ylimits(0)), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3909 zd/(zlimits(1)-zlimits(0))); |
7427 | 3910 translate (x_gl_mat1, -xo, -yo, -zo); |
3911 x_gl_mat2 = x_viewport * x_projection; | |
3912 } | |
3913 | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3914 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3915 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3916 double xlength, double ylength, double zlength) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3917 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3918 double xval = xlength/scalefactors(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3919 double yval = ylength/scalefactors(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3920 double zval = zlength/scalefactors(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3921 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3922 double minval = xmin (xmin (xval, yval), zval); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3923 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3924 aspectratios(0) = xval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3925 aspectratios(1) = yval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3926 aspectratios(2) = zval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3927 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3928 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3929 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3930 max_axes_scale (double& s, Matrix& limits, const Matrix& kids, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3931 double pbfactor, double dafactor, char limit_type, bool tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3932 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3933 if (tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3934 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3935 double minval = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3936 double maxval = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3937 double min_pos = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3938 get_children_limits (minval, maxval, min_pos, kids, limit_type); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3939 if (!xisinf (minval) && !xisnan (minval) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3940 && !xisinf (maxval) && !xisnan (maxval)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3941 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3942 limits(0) = minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3943 limits(1) = maxval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3944 s = xmax(s, (maxval - minval) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3945 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3946 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3947 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3948 s = xmax(s, (limits(1) - limits(0)) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3949 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3950 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3951 static bool updating_aspectratios = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3952 |
7427 | 3953 void |
3954 axes::properties::update_aspectratios (void) | |
3955 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3956 if (updating_aspectratios) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3957 return; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3958 |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3959 Matrix xlimits = get_xlim ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3960 Matrix ylimits = get_ylim ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3961 Matrix zlimits = get_zlim ().matrix_value (); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3962 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3963 double dx = (xlimits(1)-xlimits(0)); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3964 double dy = (ylimits(1)-ylimits(0)); |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
3965 double dz = (zlimits(1)-zlimits(0)); |
7427 | 3966 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3967 Matrix da = get_dataaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3968 Matrix pba = get_plotboxaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3969 |
7427 | 3970 if (dataaspectratiomode_is ("auto")) |
3971 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3972 if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3973 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3974 pba = Matrix (1, 3, 1.0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3975 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3976 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3977 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3978 normalized_aspectratios (da, pba, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3979 dataaspectratio.set (da, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3980 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3981 else if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3982 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3983 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3984 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3985 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3986 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3987 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3988 double s = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3989 bool modified_limits = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3990 Matrix kids; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3991 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3992 if (xlimmode_is ("auto") && ylimmode_is ("auto") && zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3993 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3994 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3995 kids = get_children (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3996 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', true); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3997 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', true); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3998 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', true); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
3999 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4000 else if (xlimmode_is ("auto") && ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4001 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4002 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4003 max_axes_scale (s, zlimits, kids, pba(2), da(2), 'z', false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4004 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4005 else if (ylimmode_is ("auto") && zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4006 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4007 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4008 max_axes_scale (s, xlimits, kids, pba(0), da(0), 'x', false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4009 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4010 else if (zlimmode_is ("auto") && xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4011 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4012 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4013 max_axes_scale (s, ylimits, kids, pba(1), da(1), 'y', false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4014 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4015 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4016 if (modified_limits) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4017 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4018 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4019 unwind_protect frame; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4020 frame.protect_var (updating_aspectratios); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4021 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4022 updating_aspectratios = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4023 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4024 dx = pba(0) *da(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4025 dy = pba(1) *da(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4026 dz = pba(2) *da(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4027 if (xisinf (s)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4028 s = 1 / xmin (xmin (dx, dy), dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4029 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4030 if (xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4031 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4032 dx = s * dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4033 xlimits(0) = 0.5 * (xlimits(0) + xlimits(1) - dx); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4034 xlimits(1) = xlimits(0) + dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4035 set_xlim (xlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4036 set_xlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4037 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4038 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4039 if (ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4040 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4041 dy = s * dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4042 ylimits(0) = 0.5 * (ylimits(0) + ylimits(1) - dy); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4043 ylimits(1) = ylimits(0) + dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4044 set_ylim (ylimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4045 set_ylimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4046 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4047 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4048 if (zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4049 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4050 dz = s * dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4051 zlimits(0) = 0.5 * (zlimits(0) + zlimits(1) - dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4052 zlimits(1) = zlimits(0) + dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4053 set_zlim (zlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4054 set_zlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4055 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4056 } |
7427 | 4057 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4058 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4059 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4060 plotboxaspectratio.set (pba, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4061 } |
7427 | 4062 } |
4063 } | |
4064 | |
7447 | 4065 // The INTERNAL flag defines whether position or outerposition is used. |
4066 | |
7427 | 4067 Matrix |
7447 | 4068 axes::properties::get_boundingbox (bool internal) const |
7427 | 4069 { |
7447 | 4070 graphics_object obj = gh_manager::get_object (get_parent ()); |
4071 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); | |
4072 Matrix pos = (internal ? | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4073 get_position ().matrix_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4074 : get_outerposition ().matrix_value ()); |
7447 | 4075 |
4076 | |
4077 pos = convert_position (pos, get_units (), "pixels", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4078 parent_bb.extract_n (0, 2, 1, 2)); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4079 |
7427 | 4080 pos(0)--; |
4081 pos(1)--; | |
7447 | 4082 pos(1) = parent_bb(3) - pos(1) - pos(3); |
7427 | 4083 |
4084 return pos; | |
4085 } | |
4086 | |
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
|
4087 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4088 axes::properties::set_units (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4089 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4090 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4091 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4092 caseless_str old_units = get_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
|
4093 if (units.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4094 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4095 update_units (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
|
4096 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4097 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4098 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4099 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4100 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4101 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4102 axes::properties::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
|
4103 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4104 graphics_object obj = gh_manager::get_object (get_parent ()); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4105 Matrix parent_bb = obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4106 caseless_str new_units = get_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
|
4107 set_position (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4108 set_outerposition (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4109 set_tightinset (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb))); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4110 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4111 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4112 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4113 axes::properties::set_fontunits (const octave_value& v) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4114 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4115 if (! error_state) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4116 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4117 caseless_str old_fontunits = get_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
|
4118 if (fontunits.set (v, true)) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4119 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4120 update_fontunits (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
|
4121 mark_modified (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4122 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4123 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4124 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4125 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4126 void |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4127 axes::properties::update_fontunits (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
|
4128 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4129 caseless_str new_units = get_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
|
4130 double fsz = get_fontsize (); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4131 double pixelsperinch = xget (0, "screenpixelsperinch").double_value(); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4132 double parent_height = get_boundingbox (true).elem (3); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4133 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4134 if (old_units.compare ("normalized")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4135 fsz = fsz * parent_height * 72 / pixelsperinch; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4136 else if (old_units.compare ("pixels")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4137 fsz = fsz * 72 / pixelsperinch; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4138 else if (old_units.compare ("inches")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4139 fsz = fsz * 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4140 else if (old_units.compare ("centimeters")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4141 fsz = fsz * 72 / 2.54; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4142 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4143 if (new_units.compare ("normalized")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4144 fsz = fsz * pixelsperinch / parent_height / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4145 else if (new_units.compare ("pixels")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4146 fsz = fsz * pixelsperinch / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4147 else if (new_units.compare ("inches")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4148 fsz = fsz / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4149 else if (new_units.compare ("centimeters")) |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4150 fsz = fsz * 2.54 / 72; |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4151 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4152 set_fontsize (octave_value (fsz)); |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4153 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
4154 |
7435 | 4155 ColumnVector |
4156 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 4157 { |
4158 return ::xform_vector (x, y, z); | |
4159 } | |
7435 | 4160 |
4161 Matrix | |
4162 graphics_xform::xform_eye (void) | |
7869 | 4163 { |
4164 return ::xform_matrix (); | |
4165 } | |
7435 | 4166 |
4167 ColumnVector | |
4168 graphics_xform::transform (double x, double y, double z, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4169 bool use_scale) const |
7435 | 4170 { |
4171 if (use_scale) | |
4172 { | |
4173 x = sx.scale (x); | |
4174 y = sy.scale (y); | |
4175 z = sz.scale (z); | |
4176 } | |
4177 | |
4178 return ::transform (xform, x, y, z); | |
4179 } | |
4180 | |
4181 ColumnVector | |
4182 graphics_xform::untransform (double x, double y, double z, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4183 bool use_scale) const |
7435 | 4184 { |
4185 ColumnVector v = ::transform (xform_inv, x, y, z); | |
4186 | |
4187 if (use_scale) | |
4188 { | |
4189 v(0) = sx.unscale (v(0)); | |
4190 v(1) = sy.unscale (v(1)); | |
4191 v(2) = sz.unscale (v(2)); | |
4192 } | |
4193 | |
4194 return v; | |
4195 } | |
4196 | |
6836 | 4197 octave_value |
7189 | 4198 axes::get_default (const caseless_str& name) const |
6836 | 4199 { |
4200 octave_value retval = default_properties.lookup (name); | |
4201 | |
4202 if (retval.is_undefined ()) | |
4203 { | |
4204 graphics_handle parent = get_parent (); | |
4205 graphics_object parent_obj = gh_manager::get_object (parent); | |
4206 | |
4207 retval = parent_obj.get_default (name); | |
4208 } | |
4209 | |
4210 return retval; | |
4211 } | |
4212 | |
8333 | 4213 // FIXME -- remove. |
4214 // FIXME -- maybe this should go into array_property class? | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4215 /* |
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
|
4216 static 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
|
4217 check_limit_vals (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4218 const array_property& 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
|
4219 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4220 double val = data.min_val (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4221 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4222 min_val = val; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4223 val = data.max_val (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4224 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4225 max_val = val; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4226 val = data.min_pos (); |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4227 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4228 min_pos = val; |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
4229 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4230 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4231 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4232 static void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4233 check_limit_vals (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4234 const octave_value& data) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4235 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4236 if (data.is_matrix_type ()) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4237 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4238 Matrix m = data.matrix_value (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4239 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4240 if (! error_state && m.numel () == 3) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4241 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4242 double val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4243 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4244 val = m(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4245 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4246 min_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4247 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4248 val = m(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4249 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4250 max_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4251 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4252 val = m(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4253 if (! (xisinf (val) || xisnan (val)) && val > 0 && val < min_pos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4254 min_pos = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4255 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4256 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4257 } |
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
|
4258 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4259 // magform(x) Returns (a, b), where x = a * 10^b, a >= 1., and b is |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4260 // integral. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4261 |
7869 | 4262 static void |
4263 magform (double x, double& a, int& b) | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4264 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4265 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4266 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4267 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4268 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4269 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4270 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4271 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4272 double l = std::log10 (std::abs (x)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4273 double r = std::fmod (l, 1.); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4274 a = std::pow (10.0, r); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4275 b = static_cast<int> (l-r); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4276 if (a < 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4277 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4278 a *= 10; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4279 b -= 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4280 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4281 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4282 if (x < 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4283 a = -a; |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4284 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4285 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4286 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4287 // A translation from Tom Holoryd's python code at |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4288 // http://kurage.nimh.nih.gov/tomh/tics.py |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4289 // FIXME -- add log ticks |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4290 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4291 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4292 axes::properties::calc_tick_sep (double lo, double hi) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4293 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4294 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4295 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4296 // Reference: Lewart, C. R., "Algorithms SCALE1, SCALE2, and |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4297 // SCALE3 for Determination of Scales on Computer Generated |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4298 // Plots", Communications of the ACM, 10 (1973), 639-640. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4299 // Also cited as ACM Algorithm 463. |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4300 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4301 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4302 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4303 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4304 magform ((hi-lo)/ticint, a, b); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4305 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4306 static const double sqrt_2 = sqrt (2.0); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4307 static const double sqrt_10 = sqrt (10.0); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4308 static const double sqrt_50 = sqrt (50.0); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4309 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4310 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4311 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4312 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4313 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4314 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4315 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4316 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4317 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4318 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4319 return x * std::pow (10., b); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4320 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4321 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4322 |
7222 | 4323 // Attempt to make "nice" limits from the actual max and min of the |
4324 // data. For log plots, we will also use the smallest strictly positive | |
4325 // value. | |
4326 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4327 Matrix |
7869 | 4328 axes::properties::get_axis_limits (double xmin, double xmax, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4329 double min_pos, bool logscale) |
7222 | 4330 { |
4331 Matrix retval; | |
4332 | |
4333 double min_val = xmin; | |
4334 double max_val = xmax; | |
4335 | |
4336 if (! (xisinf (min_val) || xisinf (max_val))) | |
4337 { | |
4338 if (logscale) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4339 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4340 if (xisinf (min_pos)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4341 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4342 // warning ("axis: logscale with no positive values to plot"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4343 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4344 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4345 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4346 if (min_val <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4347 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4348 warning ("axis: omitting nonpositive data in log plot"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4349 min_val = min_pos; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4350 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4351 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4352 if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4353 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4354 min_val *= 0.9; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4355 max_val *= 1.1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4356 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4357 min_val = pow (10, floor (log10 (min_val))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4358 max_val = pow (10, ceil (log10 (max_val))); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4359 } |
7222 | 4360 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4361 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4362 if (min_val == 0 && max_val == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4363 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4364 min_val = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4365 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4366 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4367 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4368 else if (std::abs (min_val - max_val) < sqrt (DBL_EPSILON)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4369 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4370 min_val -= 0.1 * std::abs (min_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4371 max_val += 0.1 * std::abs (max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4372 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4373 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4374 double tick_sep = calc_tick_sep (min_val , max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4375 min_val = tick_sep * std::floor (min_val / tick_sep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4376 max_val = tick_sep * ceil (max_val / tick_sep); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4377 } |
7222 | 4378 } |
4379 | |
4380 retval.resize (1, 2); | |
4381 | |
4382 retval(0) = min_val; | |
4383 retval(1) = max_val; | |
4384 | |
4385 return retval; | |
4386 } | |
4387 | |
7446 | 4388 void |
7869 | 4389 axes::properties::calc_ticks_and_lims (array_property& lims, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4390 array_property& ticks, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4391 bool limmode_is_auto, bool is_logscale) |
7446 | 4392 { |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4393 // FIXME -- add log ticks and lims |
7446 | 4394 |
4395 if (lims.get ().is_empty ()) | |
4396 return; | |
4397 | |
4398 double lo = (lims.get ().matrix_value ()) (0); | |
4399 double hi = (lims.get ().matrix_value ()) (1); | |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4400 // FIXME should this be checked for somewhere else? (i.e. set{x,y,z}lim) |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4401 if (hi < lo) |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4402 { |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4403 double tmp = hi; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4404 hi = lo; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4405 lo = tmp; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
4406 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4407 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4408 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4409 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4410 // FIXME we should check for negtives here |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4411 hi = std::log10 (hi); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4412 lo = std::log10 (lo); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4413 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4414 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4415 double tick_sep = calc_tick_sep (lo , hi); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4416 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4417 int i1 = static_cast<int> (std::floor (lo / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4418 int i2 = static_cast<int> (std::ceil (hi / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4419 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4420 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4421 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4422 // adjust limits to include min and max tics |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4423 Matrix tmp_lims (1,2); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4424 tmp_lims(0) = tick_sep * i1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4425 tmp_lims(1) = tick_sep * i2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4426 |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4427 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4428 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4429 tmp_lims(0) = std::pow (10.,tmp_lims(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4430 tmp_lims(1) = std::pow (10.,tmp_lims(1)); |
10941
97294dd3ccd4
graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents:
10923
diff
changeset
|
4431 if (tmp_lims(0) <= 0) |
97294dd3ccd4
graphics.cc: Fix axes limits underflow to zero for logscale.
Ben Abbott <bpabbott@mac.com>
parents:
10923
diff
changeset
|
4432 tmp_lims(0) = std::pow (10., lo); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4433 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4434 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4435 } |
7446 | 4436 else |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4437 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4438 // adjust min and max tics if they are out of limits |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4439 i1 = static_cast<int> (std::ceil (lo / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4440 i2 = static_cast<int> (std::floor (hi / tick_sep)); |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4441 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4442 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4443 Matrix tmp_ticks (1, i2-i1+1); |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4444 for (int i = 0; i <= i2-i1; i++) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4445 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4446 tmp_ticks (i) = tick_sep * (i+i1); |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4447 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4448 tmp_ticks (i) = std::pow (10., tmp_ticks (i)); |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
4449 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4450 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
4451 ticks = tmp_ticks; |
7446 | 4452 } |
4453 | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4454 void |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4455 axes::properties::calc_ticklabels (const array_property& ticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4456 any_property& labels, bool /*logscale*/) |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4457 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4458 Matrix values = ticks.get ().matrix_value (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4459 Cell c (values.dims ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4460 std::ostringstream os; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4461 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4462 for (int i = 0; i < values.numel (); i++) |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4463 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4464 os.str (std::string ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4465 os << values(i); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4466 c(i) = os.str (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4467 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4468 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4469 labels = c; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4470 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
4471 |
9455 | 4472 void |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4473 get_children_limits (double& min_val, double& max_val, double& min_pos, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4474 const Matrix& kids, char limit_type) |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4475 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4476 octave_idx_type n = kids.numel (); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4477 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4478 switch (limit_type) |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4479 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4480 case 'x': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4481 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4482 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4483 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4484 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4485 if (obj.is_xliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4486 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4487 octave_value lim = obj.get_xlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4488 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4489 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4490 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4491 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4492 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4493 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4494 case 'y': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4495 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4496 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4497 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4498 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4499 if (obj.is_yliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4500 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4501 octave_value lim = obj.get_ylim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4502 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4503 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4504 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4505 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4506 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4507 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4508 case 'z': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4509 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4510 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4511 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4512 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4513 if (obj.is_zliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4514 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4515 octave_value lim = obj.get_zlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4516 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4517 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4518 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4519 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4520 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4521 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4522 case 'c': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4523 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4524 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4525 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4526 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4527 if (obj.is_climinclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4528 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4529 octave_value lim = obj.get_clim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4530 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4531 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4532 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4533 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4534 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4535 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4536 case 'a': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4537 for (octave_idx_type i = 0; i < n; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4538 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4539 graphics_object obj = gh_manager::get_object (kids(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4540 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4541 if (obj.is_aliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4542 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4543 octave_value lim = obj.get_alim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4544 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4545 check_limit_vals (min_val, max_val, min_pos, lim); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4546 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4547 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4548 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4549 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4550 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4551 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4552 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4553 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4554 |
7222 | 4555 static bool updating_axis_limits = false; |
4556 | |
7214 | 4557 void |
7222 | 4558 axes::update_axis_limits (const std::string& axis_type) |
7214 | 4559 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
4560 if (updating_axis_limits || updating_aspectratios) |
7222 | 4561 return; |
4562 | |
4563 Matrix kids = xproperties.get_children (); | |
4564 | |
4565 double min_val = octave_Inf; | |
4566 double max_val = -octave_Inf; | |
4567 double min_pos = octave_Inf; | |
4568 | |
4569 char update_type = 0; | |
4570 | |
4571 Matrix limits; | |
4572 | |
4573 if (axis_type == "xdata" || axis_type == "xscale" | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4574 || axis_type == "xlimmode" || axis_type == "xliminclude" |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4575 || axis_type == "xlim") |
7222 | 4576 { |
7363 | 4577 if (xproperties.xlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4578 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4579 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4580 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4581 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4582 xproperties.xscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4583 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4584 update_type = 'x'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4585 } |
7222 | 4586 } |
4587 else if (axis_type == "ydata" || axis_type == "yscale" | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4588 || axis_type == "ylimmode" || axis_type == "yliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4589 || axis_type == "ylim") |
7222 | 4590 { |
7363 | 4591 if (xproperties.ylimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4592 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4593 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4594 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4595 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4596 xproperties.yscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4597 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4598 update_type = 'y'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4599 } |
7222 | 4600 } |
4601 else if (axis_type == "zdata" || axis_type == "zscale" | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4602 || axis_type == "zlimmode" || axis_type == "zliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4603 || axis_type == "zlim") |
7222 | 4604 { |
7363 | 4605 if (xproperties.zlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4606 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4607 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4608 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4609 limits = xproperties.get_axis_limits (min_val, max_val, min_pos, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4610 xproperties.zscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4611 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4612 update_type = 'z'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4613 } |
7222 | 4614 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4615 else if (axis_type == "cdata" || axis_type == "climmode" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4616 || axis_type == "cdatamapping" || axis_type == "climinclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4617 || axis_type == "clim") |
7222 | 4618 { |
7363 | 4619 if (xproperties.climmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4620 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4621 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4622 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4623 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4624 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4625 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4626 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4627 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4628 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4629 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4630 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4631 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4632 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4633 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4634 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4635 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4636 update_type = 'c'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4637 } |
7222 | 4638 |
4639 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4640 else if (axis_type == "alphadata" || axis_type == "alimmode" |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4641 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4642 || axis_type == "alim") |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4643 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4644 if (xproperties.alimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4645 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4646 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4647 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4648 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4649 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4650 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4651 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4652 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4653 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4654 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4655 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4656 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4657 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4658 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4659 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4660 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4661 update_type = 'a'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4662 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4663 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4664 } |
7222 | 4665 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4666 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4667 frame.protect_var (updating_axis_limits); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
4668 |
7222 | 4669 updating_axis_limits = true; |
4670 | |
4671 switch (update_type) | |
4672 { | |
4673 case 'x': | |
4674 xproperties.set_xlim (limits); | |
4675 xproperties.set_xlimmode ("auto"); | |
7446 | 4676 xproperties.update_xlim (); |
7222 | 4677 break; |
4678 | |
4679 case 'y': | |
4680 xproperties.set_ylim (limits); | |
4681 xproperties.set_ylimmode ("auto"); | |
7446 | 4682 xproperties.update_ylim (); |
7222 | 4683 break; |
4684 | |
4685 case 'z': | |
4686 xproperties.set_zlim (limits); | |
4687 xproperties.set_zlimmode ("auto"); | |
7446 | 4688 xproperties.update_zlim (); |
7222 | 4689 break; |
4690 | |
4691 case 'c': | |
4692 xproperties.set_clim (limits); | |
4693 xproperties.set_climmode ("auto"); | |
4694 break; | |
4695 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4696 case 'a': |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4697 xproperties.set_alim (limits); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4698 xproperties.set_alimmode ("auto"); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4699 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4700 |
7222 | 4701 default: |
4702 break; | |
4703 } | |
4704 | |
7427 | 4705 xproperties.update_transform (); |
7214 | 4706 } |
4707 | |
9455 | 4708 inline |
4709 double force_in_range (const double x, const double lower, const double upper) | |
4710 { | |
4711 if (x < lower) | |
4712 { return lower; } | |
4713 else if (x > upper) | |
4714 { return upper; } | |
4715 else | |
4716 { return x; } | |
4717 } | |
4718 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4719 void |
9455 | 4720 axes::properties::zoom_about_point (double x, double y, double factor, |
4721 bool push_to_zoom_stack) | |
4722 { | |
4723 // FIXME: Do we need error checking here? | |
4724 Matrix xlims = get_xlim ().matrix_value (); | |
4725 Matrix ylims = get_ylim ().matrix_value (); | |
4726 | |
4727 // Get children axes limits | |
4728 Matrix kids = get_children (); | |
4729 double minx = octave_Inf; | |
4730 double maxx = -octave_Inf; | |
4731 double min_pos_x = octave_Inf; | |
4732 get_children_limits (minx, maxx, min_pos_x, kids, 'x'); | |
4733 | |
4734 double miny = octave_Inf; | |
4735 double maxy = -octave_Inf; | |
4736 double min_pos_y = octave_Inf; | |
4737 get_children_limits (miny, maxy, min_pos_y, kids, 'y'); | |
4738 | |
4739 // Perform the zooming | |
4740 xlims (0) = x + factor * (xlims (0) - x); | |
4741 xlims (1) = x + factor * (xlims (1) - x); | |
4742 ylims (0) = y + factor * (ylims (0) - y); | |
4743 ylims (1) = y + factor * (ylims (1) - y); | |
4744 | |
4745 zoom (xlims, ylims, push_to_zoom_stack); | |
4746 } | |
4747 | |
4748 void | |
4749 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack) | |
4750 { | |
4751 if (push_to_zoom_stack) | |
4752 { | |
4753 zoom_stack.push_front (xlimmode.get ()); | |
4754 zoom_stack.push_front (xlim.get ()); | |
4755 zoom_stack.push_front (ylimmode.get ()); | |
4756 zoom_stack.push_front (ylim.get ()); | |
4757 } | |
4758 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4759 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4760 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4761 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4762 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4763 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4764 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4765 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4766 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4767 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4768 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4769 void |
9455 | 4770 axes::properties::translate_view (double delta_x, double delta_y) |
4771 { | |
4772 // FIXME: Do we need error checking here? | |
4773 Matrix xlims = get_xlim ().matrix_value (); | |
4774 Matrix ylims = get_ylim ().matrix_value (); | |
4775 | |
4776 // Get children axes limits | |
4777 Matrix kids = get_children (); | |
4778 double minx = octave_Inf; | |
4779 double maxx = -octave_Inf; | |
4780 double min_pos_x = octave_Inf; | |
4781 get_children_limits (minx, maxx, min_pos_x, kids, 'x'); | |
4782 | |
4783 double miny = octave_Inf; | |
4784 double maxy = -octave_Inf; | |
4785 double min_pos_y = octave_Inf; | |
4786 get_children_limits (miny, maxy, min_pos_y, kids, 'y'); | |
4787 | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4788 xlims (0) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4789 xlims (1) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4790 ylims (0) += delta_y; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4791 ylims (1) += delta_y; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4792 |
9455 | 4793 zoom (xlims, ylims, false); |
4794 } | |
4795 | |
4796 void | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4797 axes::properties::rotate_view (double delta_el, double delta_az) |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4798 { |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4799 Matrix v = get_view ().matrix_value (); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4800 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4801 v (1) += delta_el; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4802 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4803 if(v(1) > 90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4804 v(1) = 90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4805 if(v(1) < -90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4806 v(1) = -90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4807 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4808 v (0) = fmod(v(0) - delta_az + 720,360); |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4809 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4810 set_view(v); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4811 update_transform(); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4812 } |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4813 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
4814 void |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4815 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4816 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4817 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4818 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4819 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4820 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4821 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4822 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4823 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4824 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4825 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4826 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4827 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4828 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4829 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4830 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4831 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4832 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4833 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4834 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4835 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4836 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4837 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4838 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4839 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4840 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4841 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
4842 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4843 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4844 axes::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4845 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
4846 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4847 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
4848 |
7363 | 4849 // --------------------------------------------------------------------- |
4850 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4851 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4852 line::properties::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
|
4853 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4854 Matrix m (1, 3); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4855 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4856 m(0) = xdata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4857 m(1) = xdata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4858 m(2) = xdata.min_pos (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4859 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4860 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
|
4861 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4862 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4863 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4864 line::properties::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
|
4865 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4866 Matrix m (1, 3); |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4867 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4868 m(0) = ydata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4869 m(1) = ydata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
4870 m(2) = ydata.min_pos (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4871 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
4872 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
|
4873 } |
6406 | 4874 |
4875 // --------------------------------------------------------------------- | |
4876 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4877 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4878 text::properties::get_data_position (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4879 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4880 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4881 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4882 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4883 pos = convert_text_position (pos, *this, get_units (), "data"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4884 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4885 return pos; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4886 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4887 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4888 octave_value |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4889 text::properties::get_extent (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4890 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4891 Matrix m = extent.get ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4892 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4893 return convert_text_position (m, *this, "pixels", get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4894 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4895 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4896 void |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4897 text::properties::update_text_extent (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4898 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4899 #ifdef HAVE_FREETYPE |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4900 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4901 text_element *elt; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4902 ft_render text_renderer; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4903 Matrix box; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4904 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4905 // FIXME: parsed content should be cached for efficiency |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4906 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4907 elt = text_parser_none ().parse (get_string ()); |
10526
660c244d3206
Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents:
10402
diff
changeset
|
4908 #ifdef HAVE_FONTCONFIG |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4909 text_renderer.set_font (*this); |
10526
660c244d3206
Don't call text_renderer.set_font if HAVE_FONTCONFIG is not set (bug #29570)
David Bateman <dbateman@free.fr>
parents:
10402
diff
changeset
|
4910 #endif |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4911 box = text_renderer.get_extent (elt, get_rotation ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4912 |
10553 | 4913 Matrix ext (1, 4, 0.0); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4914 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4915 // FIXME: also handle left and bottom components |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4916 |
10553 | 4917 ext(0) = ext(1) = 1; |
4918 ext(2) = box(0); | |
4919 ext(3) = box(1); | |
4920 | |
4921 set_extent (ext); | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4922 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4923 #endif |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4924 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4925 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4926 void |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4927 text::properties::update_units (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4928 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4929 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4930 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4931 set_xliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4932 set_yliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4933 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4934 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4935 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4936 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4937 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4938 pos = convert_text_position (pos, *this, cached_units, get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4939 // FIXME: if the current axes view is 2D, then one should |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4940 // probably drop the z-component of "pos" and leave "zliminclude" |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4941 // to "off". |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4942 set_position (pos); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4943 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4944 if (units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4945 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4946 set_xliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4947 set_yliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4948 // FIXME: see above |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4949 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4950 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4951 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4952 cached_units = get_units (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
4953 } |
6406 | 4954 |
4955 // --------------------------------------------------------------------- | |
4956 | |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
4957 octave_value |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
4958 image::properties::get_color_data (void) const |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
4959 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
4960 return convert_cdata (*this, get_cdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4961 cdatamapping_is ("scaled"), 3); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
4962 } |
6406 | 4963 |
4964 // --------------------------------------------------------------------- | |
4965 | |
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:
7829
diff
changeset
|
4966 octave_value |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
4967 patch::properties::get_color_data (void) const |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
4968 { |
8ff92634982d
Add initial support for patch rendering through GLU tessellation (no transparency, no border, no markers yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7829
diff
changeset
|
4969 return convert_cdata (*this, get_facevertexcdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4970 cdatamapping_is ("scaled"), 2); |
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:
7829
diff
changeset
|
4971 } |
6807 | 4972 |
4973 // --------------------------------------------------------------------- | |
4974 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4975 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4976 surface::properties::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
|
4977 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4978 return convert_cdata (*this, get_cdata (), cdatamapping_is ("scaled"), 3); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4979 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4980 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4981 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4982 cross_product (double x1, double y1, double z1, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4983 double x2, double y2, double z2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4984 double& x, double& y, double& z) |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4985 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4986 x += (y1 * z2 - z1 * y2); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4987 y += (z1 * x2 - x1 * z2); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4988 z += (x1 * y2 - y1 * x2); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4989 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4990 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4991 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4992 surface::properties::update_normals (void) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4993 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4994 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4995 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4996 Matrix x = get_xdata ().matrix_value (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4997 Matrix y = get_ydata ().matrix_value (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4998 Matrix z = get_zdata ().matrix_value (); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
4999 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5000 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5001 int p = z.columns (), q = z.rows (); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5002 int i1 = 0, i2 = 0, i3 = 0; |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5003 int j1 = 0, j2 = 0, j3 = 0; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5004 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5005 bool x_mat = (x.rows () == q); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5006 bool y_mat = (y.columns () == p); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5007 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5008 NDArray n (dim_vector (q, p, 3), 0.0); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5009 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5010 for (int i = 0; i < p; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5011 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5012 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5013 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5014 i1 = i - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5015 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5016 i3 = i + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5017 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5018 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5019 for (int j = 0; j < q; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5020 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5021 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5022 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5023 j1 = j - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5024 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5025 j3 = j + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5026 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5027 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5028 double& nx = n(j, i, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5029 double& ny = n(j, i, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5030 double& nz = n(j, i, 2); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5031 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5032 if ((j > 0) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5033 // upper left quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5034 cross_product (x(j1,i-1)-x(j2,i), y(j-1,i1)-y(j,i2), z(j-1,i-1)-z(j,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5035 x(j2,i-1)-x(j1,i), y(j,i1)-y(j-1,i2), z(j,i-1)-z(j-1,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5036 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5037 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5038 if ((j > 0) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5039 // upper right quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5040 cross_product (x(j1,i+1)-x(j2,i), y(j-1,i3)-y(j,i2), z(j-1,i+1)-z(j,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5041 x(j1,i)-x(j2,i+1), y(j-1,i2)-y(j,i3), z(j-1,i)-z(j,i+1), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5042 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5043 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5044 if ((j < (q - 1)) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5045 // lower left quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5046 cross_product (x(j2,i-1)-x(j3,i), y(j,i1)-y(j+1,i2), z(j,i-1)-z(j+1,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5047 x(j3,i-1)-x(j2,i), y(j+1,i1)-y(j,i2), z(j+1,i-1)-z(j,i), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5048 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5049 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5050 if ((j < (q - 1)) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5051 // lower right quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5052 cross_product (x(j3,i)-x(j2,i+1), y(j+1,i2)-y(j,i3), z(j+1,i)-z(j,i+1), |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5053 x(j3,i+1)-x(j2,i), y(j+1,i3)-y(j,i2), z(j+1,i+1)-z(j,i), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5054 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5055 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
5056 double d = - std::max(std::max(fabs(nx), fabs(ny)), fabs(nz)); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5057 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5058 nx /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5059 ny /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5060 nz /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5061 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5062 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5063 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5064 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
5065 } |
6406 | 5066 |
5067 // --------------------------------------------------------------------- | |
5068 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5069 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5070 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5071 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5072 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5073 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5074 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5075 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5076 double min_pos = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5077 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5078 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5079 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5080 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5081 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5082 get_children_limits (min_val, max_val, min_pos, kids, 'x'); |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
5083 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5084 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5085 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5086 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5087 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5088 get_children_limits (min_val, max_val, min_pos, kids, 'y'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5089 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5090 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5091 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5092 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5093 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5094 get_children_limits (min_val, max_val, min_pos, kids, 'z'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5095 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5096 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5097 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5098 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5099 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5100 get_children_limits (min_val, max_val, min_pos, kids, 'c'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5101 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5102 update_type = 'c'; |
11163
31e7e9f94850
Backed out changeset a981e2f56ec1
David Bateman <dbateman@free.fr>
parents:
11162
diff
changeset
|
5103 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5104 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
5105 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5106 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5107 get_children_limits (min_val, max_val, min_pos, kids, 'a'); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5108 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5109 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5110 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5111 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5112 Matrix limits (1, 3, 0.0); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5113 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5114 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5115 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5116 limits(2) = min_pos; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5117 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5118 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5119 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5120 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5121 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5122 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5123 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5124 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5125 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5126 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5127 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5128 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5129 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5130 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5131 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5132 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5133 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5134 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5135 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5136 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5137 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5138 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5139 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5140 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5141 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5142 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5143 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5144 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5145 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5146 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5147 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5148 |
6406 | 5149 octave_value |
7189 | 5150 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 5151 { |
5152 graphics_handle parent = get_parent (); | |
5153 graphics_object parent_obj = gh_manager::get_object (parent); | |
5154 | |
5155 return parent_obj.get_default (type () + name); | |
5156 } | |
5157 | |
5158 octave_value | |
7189 | 5159 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 5160 { |
5161 graphics_object parent_obj = gh_manager::get_object (0); | |
5162 | |
5163 return parent_obj.get_factory_default (type () + name); | |
5164 } | |
5165 | |
7286 | 5166 // We use a random value for the handle to avoid issues with plots and |
5167 // scalar values for the first argument. | |
6406 | 5168 gh_manager::gh_manager (void) |
7286 | 5169 : handle_map (), handle_free_list (), |
5170 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)) | |
6406 | 5171 { |
5172 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
5173 |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
5174 // Make sure the default backend is registered. |
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
5175 graphics_backend::default_backend (); |
6406 | 5176 } |
5177 | |
5178 graphics_handle | |
5179 gh_manager::do_make_graphics_handle (const std::string& go_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5180 const graphics_handle& p, bool do_createfcn) |
6406 | 5181 { |
5182 graphics_handle h = get_handle (go_name); | |
5183 | |
5184 base_graphics_object *go = 0; | |
5185 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
5186 go = make_graphics_object_from_type (go_name, h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
5187 |
6406 | 5188 if (go) |
7370 | 5189 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5190 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5191 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5192 handle_map[h] = obj; |
7370 | 5193 if (do_createfcn) |
5194 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5195 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5196 // notify backend |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5197 graphics_backend backend = go->get_backend (); |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5198 if (backend) |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
5199 backend.initialize (obj); |
7370 | 5200 } |
6406 | 5201 else |
5202 error ("gh_manager::do_make_graphics_handle: invalid object type `%s'", | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5203 go_name.c_str ()); |
6406 | 5204 |
5205 return h; | |
5206 } | |
5207 | |
5208 graphics_handle | |
5209 gh_manager::do_make_figure_handle (double val) | |
5210 { | |
5211 graphics_handle h = val; | |
5212 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5213 base_graphics_object* go = new figure (h, 0); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5214 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5215 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
5216 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5217 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5218 // notify backend |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5219 graphics_backend backend = go->get_backend (); |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5220 if (backend) |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
5221 backend.initialize (obj); |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
5222 |
6406 | 5223 return h; |
5224 } | |
5225 | |
5226 void | |
5227 gh_manager::do_push_figure (const graphics_handle& h) | |
5228 { | |
5229 do_pop_figure (h); | |
5230 | |
5231 figure_list.push_front (h); | |
5232 } | |
5233 | |
5234 void | |
5235 gh_manager::do_pop_figure (const graphics_handle& h) | |
5236 { | |
5237 for (figure_list_iterator p = figure_list.begin (); | |
5238 p != figure_list.end (); | |
5239 p++) | |
5240 { | |
5241 if (*p == h) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5242 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5243 figure_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5244 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5245 } |
6406 | 5246 } |
5247 } | |
5248 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5249 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5250 callback_event : public base_graphics_event |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5251 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5252 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5253 callback_event (const graphics_handle& h, const std::string& name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5254 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
|
5255 : base_graphics_event (), handle (h), callback_name (name), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5256 callback_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5257 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5258 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5259 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5260 gh_manager::execute_callback (handle, callback_name, callback_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5261 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5262 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5263 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5264 callback_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5265 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5266 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5267 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5268 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5269 std::string callback_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5270 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5271 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5272 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5273 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5274 function_event : public base_graphics_event |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5275 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5276 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5277 function_event (graphics_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
|
5278 : base_graphics_event (), function (fcn), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5279 function_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5280 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5281 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5282 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5283 function (function_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5284 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5285 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5286 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5287 function_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5288 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5289 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5290 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5291 graphics_event::event_fcn function; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5292 void* function_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5293 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5294 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5295 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5296 set_event : public base_graphics_event |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5297 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5298 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5299 set_event (const graphics_handle& h, const std::string& name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5300 const octave_value& value) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5301 : base_graphics_event (), handle (h), property_name (name), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5302 property_value (value) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5303 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5304 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5305 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5306 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5307 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5308 xset (handle, property_name, property_value); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5309 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5310 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5311 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5312 set_event (void) |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5313 : base_graphics_event () { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5314 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5315 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5316 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5317 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5318 octave_value property_value; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5319 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5320 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5321 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5322 graphics_event::create_callback_event (const graphics_handle& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5323 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5324 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5325 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5326 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5327 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5328 e.rep = new callback_event (h, name, data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5329 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5330 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5331 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5332 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5333 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5334 graphics_event::create_function_event (graphics_event::event_fcn fcn, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5335 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5336 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5337 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5338 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5339 e.rep = new function_event (fcn, data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5340 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5341 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5342 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5343 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5344 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5345 graphics_event::create_set_event (const graphics_handle& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5346 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5347 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5348 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5349 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5350 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5351 e.rep = new set_event (h, name, data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5352 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5353 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5354 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5355 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5356 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5357 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5358 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5359 graphics_object go = gh_manager::get_object (0); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5360 root_figure::properties& props = |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5361 dynamic_cast<root_figure::properties&> (go.get_properties ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5362 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5363 props.set_callbackobject (h.as_octave_value ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5364 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5365 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5366 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5367 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5368 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5369 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5370 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5371 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5372 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5373 xset_gcbo (callback_objects.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5374 ? graphics_handle () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5375 : callback_objects.front ().get_handle ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5376 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5377 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5378 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5379 gh_manager::do_execute_callback (const graphics_handle& h, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5380 const octave_value& cb_arg, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5381 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5382 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5383 octave_value_list args; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5384 octave_function *fcn = 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5385 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5386 args(0) = h.as_octave_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5387 if (data.is_defined ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5388 args(1) = data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5389 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5390 args(1) = Matrix (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5391 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
5392 unwind_protect_safe frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
5393 frame.add_fcn (gh_manager::restore_gcbo); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5394 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5395 if (true) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5396 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5397 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5398 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5399 callback_objects.push_front (get_object (h)); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5400 xset_gcbo (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5401 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5402 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5403 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5404 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5405 // Copy CB because "function_value" method is non-const. |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5406 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5407 octave_value cb = cb_arg; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5408 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5409 if (cb.is_function_handle ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5410 fcn = cb.function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5411 else if (cb.is_string ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5412 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5413 int status; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5414 std::string s = cb.string_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5415 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5416 eval_string (s, false, status); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5417 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5418 else if (cb.is_cell () && cb.length () > 0 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5419 && (cb.rows () == 1 || cb.columns () == 1) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5420 && cb.cell_value ()(0).is_function_handle ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5421 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5422 Cell c = cb.cell_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5423 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5424 fcn = c(0).function_value (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5425 if (! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5426 { |
8052
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
5427 for (int i = 1; i < c.length () ; i++) |
961d4c52ffae
Convert stem and stem3 to use stem series objects
David Bateman <dbateman@free.fr>
parents:
8021
diff
changeset
|
5428 args(1+i) = c(i); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5429 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5430 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5431 else |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5432 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5433 std::string nm = cb.class_name (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5434 error ("trying to execute non-executable object (class = %s)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5435 nm.c_str ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5436 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5437 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5438 if (fcn && ! error_state) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5439 feval (fcn, args); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5440 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5441 END_INTERRUPT_WITH_EXCEPTIONS; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5442 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5443 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5444 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5445 gh_manager::do_post_event (const graphics_event& e) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5446 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5447 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5448 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5449 command_editor::add_event_hook (gh_manager::process_events); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5450 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5451 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5452 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5453 gh_manager::do_post_callback (const graphics_handle& h, const std::string name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5454 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5455 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5456 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5457 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5458 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5459 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5460 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5461 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5462 if (callback_objects.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5463 do_post_event (graphics_event::create_callback_event (h, name, data)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5464 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5465 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5466 const graphics_object& current = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5467 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5468 if (current.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5469 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5470 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5471 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5472 caseless_str busy_action (go.get_properties ().get_busyaction ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5473 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5474 if (busy_action.compare ("queue")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5475 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5476 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5477 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5478 caseless_str cname (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5479 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5480 if (cname.compare ("deletefcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5481 || cname.compare ("createfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5482 || (go.isa ("figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5483 && (cname.compare ("closerequestfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5484 || cname.compare ("resizefcn")))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5485 do_post_event (graphics_event::create_callback_event (h, name, data)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5486 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5487 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5488 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5489 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5490 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5491 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5492 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5493 gh_manager::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:
7924
diff
changeset
|
5494 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5495 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5496 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5497 do_post_event (graphics_event::create_function_event (fcn, fcn_data)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5498 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5499 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5500 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5501 gh_manager::do_post_set (const graphics_handle& h, const std::string name, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5502 const octave_value& value) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5503 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5504 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5505 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5506 do_post_event (graphics_event::create_set_event (h, name, value)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5507 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5508 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5509 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5510 gh_manager::do_process_events (bool force) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5511 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5512 graphics_event e; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5513 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5514 do |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5515 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
5516 e = graphics_event (); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5517 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5518 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5519 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5520 if (! event_queue.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5521 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5522 if (callback_objects.empty () || force) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5523 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5524 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5525 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5526 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5527 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5528 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5529 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5530 const graphics_object& go = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5531 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5532 if (go.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5533 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5534 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5535 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5536 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5537 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5538 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5539 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5540 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5541 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5542 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5543 if (e.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5544 e.execute (); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5545 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5546 while (e.ok ()); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5547 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5548 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5549 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5550 if (event_queue.empty ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5551 command_editor::remove_event_hook (gh_manager::process_events); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5552 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5553 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5554 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5555 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5556 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5557 |
6406 | 5558 property_list::plist_map_type |
5559 root_figure::init_factory_properties (void) | |
5560 { | |
5561 property_list::plist_map_type plist_map; | |
5562 | |
6844 | 5563 plist_map["figure"] = figure::properties::factory_defaults (); |
5564 plist_map["axes"] = axes::properties::factory_defaults (); | |
5565 plist_map["line"] = line::properties::factory_defaults (); | |
5566 plist_map["text"] = text::properties::factory_defaults (); | |
5567 plist_map["image"] = image::properties::factory_defaults (); | |
5568 plist_map["patch"] = patch::properties::factory_defaults (); | |
5569 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5570 plist_map["hggroup"] = hggroup::properties::factory_defaults (); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
5571 plist_map["uimenu"] = uimenu::properties::factory_defaults (); |
6406 | 5572 |
5573 return plist_map; | |
5574 } | |
5575 | |
5576 // --------------------------------------------------------------------- | |
5577 | |
5578 DEFUN (ishandle, args, , | |
5579 "-*- texinfo -*-\n\ | |
6678 | 5580 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 5581 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
5582 @end deftypefn") | |
5583 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5584 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5585 |
6406 | 5586 octave_value retval; |
5587 | |
5588 if (args.length () == 1) | |
5589 retval = is_handle (args(0)); | |
5590 else | |
5591 print_usage (); | |
5592 | |
5593 return retval; | |
5594 } | |
5595 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5596 DEFUN (reset, args, , |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5597 "-*- texinfo -*-\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5598 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\ |
10840 | 5599 Removes any defaults set for the handle @var{h}. The default figure\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5600 properties \"position\", \"units\", \"windowstyle\" and\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5601 \"paperunits\" and the default axes properties \"position\" and \"units\"\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5602 are not reset.\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5603 @end deftypefn") |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5604 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5605 int nargin = args.length (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5606 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5607 if (nargin != 1) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5608 print_usage (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5609 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5610 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5611 // get vector of graphics handles |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5612 ColumnVector hcv (args(0).vector_value ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5613 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5614 if (! error_state) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5615 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5616 // loop over graphics objects |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5617 for (octave_idx_type n = 0; n < hcv.length (); n++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5618 gh_manager::get_object (hcv(n)).reset_default_properties (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5619 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5620 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5621 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5622 return octave_value (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5623 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
5624 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5625 DEFUN (set, args, nargout, |
6406 | 5626 "-*- texinfo -*-\n\ |
10840 | 5627 @deftypefn {Built-in Function} {} set (@var{h}, @var{property}, @var{value}, @dots{})\n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5628 @deftypefnx {Built-in Function} {} set (@var{h}, @var{properties}, @var{values})\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5629 @deftypefnx {Built-in Function} {} set (@var{h}, @var{pv})\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5630 Set named property values for the graphics handle (or vector of graphics\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5631 handles) @var{h}.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5632 There are three ways how to give the property names and values:\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5633 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5634 @itemize\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5635 @item as a comma separated list of @var{property}, @var{value} pairs\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5636 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5637 Here, each @var{property} is a string containing the property name, each\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5638 @var{value} is a value of the appropriate type for the property.\n\ |
10840 | 5639 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5640 @item as a cell array of strings @var{properties} containing property names\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5641 and a cell array @var{values} containing property values.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5642 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5643 In this case, the number of columns of @var{values} must match the number of\n\ |
10846
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5644 elements in @var{properties}. The first column of @var{values} contains\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5645 values for the first entry in @var{properties}, etc. The number of rows of\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5646 @var{values} must be 1 or match the number of elements of @var{h}. In the\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5647 first case, each handle in @var{h} will be assigned the same values. In the\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5648 latter case, the first handle in @var{h} will be assigned the values from\n\ |
a4f482e66b65
Grammarcheck more of the documentation.
Rik <octave@nomad.inbox5.com>
parents:
10840
diff
changeset
|
5649 the first row of @var{values} and so on.\n\ |
10840 | 5650 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5651 @item as a structure array @var{pv}\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5652 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5653 Here, the field names of @var{pv} represent the property names, and the field\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5654 values give the property values. In contrast to the previous case, all\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5655 elements of @var{pv} will be set in all handles in @var{h} independent of\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5656 the dimensions of @var{pv}.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5657 @end itemize\n\ |
6406 | 5658 @end deftypefn") |
5659 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5660 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5661 |
6406 | 5662 octave_value retval; |
5663 | |
5664 int nargin = args.length (); | |
5665 | |
5666 if (nargin > 0) | |
5667 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5668 // get vector of graphics handles |
6732 | 5669 ColumnVector hcv (args(0).vector_value ()); |
6406 | 5670 |
5671 if (! error_state) | |
6732 | 5672 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5673 bool request_drawnow = false; |
6733 | 5674 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5675 // loop over graphics objects |
6732 | 5676 for (octave_idx_type n = 0; n < hcv.length (); n++) |
5677 { | |
5678 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 5679 |
6732 | 5680 if (obj) |
5681 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5682 if (nargin == 3 && args(1).is_cellstr () |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5683 && args(2).is_cell ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5684 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5685 if (args(2).cell_value ().rows () == 1) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5686 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5687 obj.set (args(1).cellstr_value (), |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5688 args(2).cell_value (), 0); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5689 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5690 else if (hcv.length () == args(2).cell_value ().rows ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5691 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5692 obj.set (args(1).cellstr_value (), |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5693 args(2).cell_value (), n); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5694 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5695 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5696 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5697 error("set: number of graphics handles must match number of value rows (%d != %d)", |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5698 hcv.length (), args(2).cell_value ().rows ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5699 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5700 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5701 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5702 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5703 else if (nargin == 2 && args(1).is_map ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5704 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5705 obj.set (args(1).map_value ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5706 } |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5707 else if (nargin == 1) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5708 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5709 if (nargout != 0) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5710 retval = obj.values_as_struct (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5711 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5712 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5713 std::string s = obj.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5714 if (! error_state) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5715 octave_stdout << s; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5716 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
5717 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5718 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5719 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5720 obj.set (args.splice (0, 1)); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5721 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5722 } |
6732 | 5723 } |
5724 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5725 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5726 error ("set: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5727 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5728 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5729 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5730 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5731 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5732 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5733 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
5734 } |
6733 | 5735 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5736 if (! error_state && request_drawnow) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5737 Vdrawnow_requested = true; |
6732 | 5738 } |
6406 | 5739 else |
6732 | 5740 error ("set: expecting graphics handle as first argument"); |
6406 | 5741 } |
5742 else | |
5743 print_usage (); | |
5744 | |
5745 return retval; | |
5746 } | |
5747 | |
5748 DEFUN (get, args, , | |
5749 "-*- texinfo -*-\n\ | |
6678 | 5750 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406 | 5751 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
5752 If @var{p} is omitted, return the complete property list for @var{h}.\n\ | |
6732 | 5753 If @var{h} is a vector, return a cell array including the property\n\ |
5754 values or lists respectively.\n\ | |
6406 | 5755 @end deftypefn") |
5756 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5757 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5758 |
6406 | 5759 octave_value retval; |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5760 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5761 Cell vals; |
6406 | 5762 |
5763 int nargin = args.length (); | |
5764 | |
5765 if (nargin == 1 || nargin == 2) | |
5766 { | |
6732 | 5767 ColumnVector hcv (args(0).vector_value ()); |
6406 | 5768 |
5769 if (! error_state) | |
6732 | 5770 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5771 octave_idx_type len = hcv.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5772 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5773 vals.resize (dim_vector (len, 1)); |
6733 | 5774 |
5775 for (octave_idx_type n = 0; n < len; n++) | |
6732 | 5776 { |
5777 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 5778 |
6732 | 5779 if (obj) |
5780 { | |
5781 if (nargin == 1) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5782 vals(n) = obj.get (); |
6732 | 5783 else |
5784 { | |
7189 | 5785 caseless_str property = args(1).string_value (); |
6406 | 5786 |
6732 | 5787 if (! error_state) |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5788 vals(n) = obj.get (property); |
6732 | 5789 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5790 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5791 error ("get: expecting property name as second argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5792 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5793 } |
6732 | 5794 } |
5795 } | |
5796 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5797 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5798 error ("get: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5799 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5800 } |
6732 | 5801 } |
5802 } | |
6406 | 5803 else |
6732 | 5804 error ("get: expecting graphics handle as first argument"); |
6406 | 5805 } |
5806 else | |
5807 print_usage (); | |
5808 | |
6733 | 5809 if (! error_state) |
6732 | 5810 { |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5811 octave_idx_type len = vals.numel (); |
6733 | 5812 |
5813 if (len > 1) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5814 retval = vals; |
6733 | 5815 else if (len == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5816 retval = vals(0); |
6732 | 5817 } |
5818 | |
6406 | 5819 return retval; |
5820 } | |
5821 | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
5822 // Return all properties from the graphics handle @var{h}. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
5823 // If @var{h} is a vector, return a cell array including the |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
5824 // property values or lists respectively. |
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
5825 |
7379 | 5826 DEFUN (__get__, args, , |
5827 "-*- texinfo -*-\n\ | |
5828 @deftypefn {Built-in Function} {} __get__ (@var{h})\n\ | |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
5829 Undocumented internal function.\n\ |
7379 | 5830 @end deftypefn") |
5831 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5832 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5833 |
7379 | 5834 octave_value retval; |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5835 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5836 Cell vals; |
7379 | 5837 |
5838 int nargin = args.length (); | |
5839 | |
5840 if (nargin == 1) | |
5841 { | |
5842 ColumnVector hcv (args(0).vector_value ()); | |
5843 | |
5844 if (! error_state) | |
5845 { | |
5846 octave_idx_type len = hcv.length (); | |
5847 | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5848 vals.resize (dim_vector (len, 1)); |
7379 | 5849 |
5850 for (octave_idx_type n = 0; n < len; n++) | |
5851 { | |
5852 graphics_object obj = gh_manager::get_object (hcv(n)); | |
5853 | |
5854 if (obj) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5855 vals(n) = obj.get (true); |
7379 | 5856 else |
5857 { | |
5858 error ("get: invalid handle (= %g)", hcv(n)); | |
5859 break; | |
5860 } | |
5861 } | |
5862 } | |
5863 else | |
5864 error ("get: expecting graphics handle as first argument"); | |
5865 } | |
5866 else | |
5867 print_usage (); | |
5868 | |
5869 if (! error_state) | |
5870 { | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5871 octave_idx_type len = vals.numel (); |
7379 | 5872 |
5873 if (len > 1) | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5874 retval = vals; |
7379 | 5875 else if (len == 1) |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
5876 retval = vals(0); |
7379 | 5877 } |
5878 | |
5879 return retval; | |
5880 } | |
5881 | |
6406 | 5882 static octave_value |
5883 make_graphics_object (const std::string& go_name, | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5884 const octave_value_list& args) |
6406 | 5885 { |
5886 octave_value retval; | |
5887 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5888 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5889 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5890 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5891 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5892 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5893 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5894 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5895 if (xargs(i).is_string () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5896 && p.compare (xargs(i).string_value ())) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5897 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5898 if (i < (xargs.length () - 1)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5899 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5900 val = xargs(i+1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5901 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5902 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5903 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5904 xargs = xargs.splice (i, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5905 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5906 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5907 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5908 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5909 error ("__go_%s__: missing value for parent property", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5910 go_name.c_str ()); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5911 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5912 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5913 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
5914 val = args(0).double_value (); |
6406 | 5915 |
5916 if (! error_state) | |
5917 { | |
5918 graphics_handle parent = gh_manager::lookup (val); | |
5919 | |
7056 | 5920 if (parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5921 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5922 graphics_handle h |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5923 = gh_manager::make_graphics_handle (go_name, parent, false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5924 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5925 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5926 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5927 adopt (parent, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5928 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5929 xset (h, xargs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5930 xcreatefcn (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5931 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5932 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5933 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5934 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5935 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5936 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5937 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5938 error ("__go%s__: unable to create graphics handle", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5939 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5940 } |
6406 | 5941 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5942 error ("__go_%s__: invalid parent", go_name.c_str ()); |
6406 | 5943 } |
5944 else | |
5945 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
5946 | |
5947 return retval; | |
5948 } | |
5949 | |
5950 DEFUN (__go_figure__, args, , | |
5951 "-*- texinfo -*-\n\ | |
5952 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ | |
6945 | 5953 Undocumented internal function.\n\ |
6406 | 5954 @end deftypefn") |
5955 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5956 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
5957 |
6406 | 5958 octave_value retval; |
5959 | |
5960 if (args.length () > 0) | |
5961 { | |
5962 double val = args(0).double_value (); | |
5963 | |
5964 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5965 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5966 if (is_figure (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5967 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5968 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5969 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5970 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5971 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5972 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5973 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5974 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5975 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5976 graphics_handle h = octave_NaN; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5977 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5978 if (xisnan (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5979 h = gh_manager::make_graphics_handle ("figure", 0, false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5980 else if (val > 0 && D_NINT (val) == val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5981 h = gh_manager::make_figure_handle (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5982 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5983 error ("__go_figure__: invalid figure number"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5984 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5985 if (! error_state && h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5986 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5987 adopt (0, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5988 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5989 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5990 xcreatefcn (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5991 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5992 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5993 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5994 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5995 error ("__go_figure__: failed to create figure handle"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5996 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5997 } |
6406 | 5998 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5999 error ("__go_figure__: expecting figure number to be double value"); |
6406 | 6000 } |
6001 else | |
6002 print_usage (); | |
6003 | |
6004 return retval; | |
6005 } | |
6006 | |
6007 #define GO_BODY(TYPE) \ | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6008 gh_manager::autolock guard; \ |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6009 \ |
6406 | 6010 octave_value retval; \ |
6011 \ | |
6012 if (args.length () > 0) \ | |
6013 retval = make_graphics_object (#TYPE, args); \ | |
6014 else \ | |
6015 print_usage (); \ | |
6016 \ | |
6017 return retval | |
6018 | |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6019 int |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6020 calc_dimensions (const graphics_object& go) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6021 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6022 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6023 int nd = 2; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6024 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6025 if (go.isa ("surface")) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6026 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6027 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6028 if ((go.isa ("line") || go.isa ("patch")) && ! go.get("zdata").is_empty ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6029 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6030 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6031 Matrix kids = go.get_properties().get_children (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6032 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6033 for (octave_idx_type i = 0; i < kids.length (); i++) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6034 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6035 graphics_handle hnd = gh_manager::lookup (kids(i)); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6036 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6037 if (hnd.ok ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6038 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6039 const graphics_object& kid = gh_manager::get_object(hnd); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6040 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6041 if (kid.valid_object()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6042 nd = calc_dimensions (kid); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6043 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6044 if (nd == 3) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6045 break; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6046 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6047 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6048 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6049 return nd; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6050 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6051 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6052 DEFUN (__calc_dimensions__, args, , |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6053 "-*- texinfo -*-\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6054 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6055 Internal function. Determine the number of dimensions in a graphics\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6056 object, whether 2 or 3.\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6057 @end deftypefn") |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6058 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6059 gh_manager::autolock guard; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6060 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6061 octave_value retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6062 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6063 int nargin = args.length (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6064 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6065 if (nargin == 1) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6066 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6067 double h = args(0).double_value (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6068 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6069 if (! error_state) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6070 retval = calc_dimensions (gh_manager::get_object (h)); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6071 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6072 error ("__calc_dimensions__: expecting graphics handle as only argument"); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6073 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6074 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6075 print_usage (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6076 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6077 return retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6078 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6079 |
6406 | 6080 DEFUN (__go_axes__, args, , |
6081 "-*- texinfo -*-\n\ | |
6082 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ | |
6945 | 6083 Undocumented internal function.\n\ |
6406 | 6084 @end deftypefn") |
6085 { | |
6086 GO_BODY (axes); | |
6087 } | |
6088 | |
6089 DEFUN (__go_line__, args, , | |
6090 "-*- texinfo -*-\n\ | |
6091 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ | |
6945 | 6092 Undocumented internal function.\n\ |
6406 | 6093 @end deftypefn") |
6094 { | |
6095 GO_BODY (line); | |
6096 } | |
6097 | |
6098 DEFUN (__go_text__, args, , | |
6099 "-*- texinfo -*-\n\ | |
6100 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ | |
6945 | 6101 Undocumented internal function.\n\ |
6406 | 6102 @end deftypefn") |
6103 { | |
6104 GO_BODY (text); | |
6105 } | |
6106 | |
6107 DEFUN (__go_image__, args, , | |
6108 "-*- texinfo -*-\n\ | |
6109 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ | |
6945 | 6110 Undocumented internal function.\n\ |
6406 | 6111 @end deftypefn") |
6112 { | |
6113 GO_BODY (image); | |
6114 } | |
6115 | |
6116 DEFUN (__go_surface__, args, , | |
6117 "-*- texinfo -*-\n\ | |
6118 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ | |
6945 | 6119 Undocumented internal function.\n\ |
6406 | 6120 @end deftypefn") |
6121 { | |
6122 GO_BODY (surface); | |
6123 } | |
6124 | |
6807 | 6125 DEFUN (__go_patch__, args, , |
6126 "-*- texinfo -*-\n\ | |
6127 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ | |
6945 | 6128 Undocumented internal function.\n\ |
6807 | 6129 @end deftypefn") |
6130 { | |
6131 GO_BODY (patch); | |
6132 } | |
6133 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6134 DEFUN (__go_hggroup__, args, , |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6135 "-*- texinfo -*-\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6136 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6137 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6138 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6139 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6140 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6141 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6142 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6143 DEFUN (__go_uimenu__, args, , |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6144 "-*- texinfo -*-\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6145 @deftypefn {Built-in Function} {} __go_uimenu__ (@var{parent})\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6146 Undocumented internal function.\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6147 @end deftypefn") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6148 { |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6149 GO_BODY (uimenu); |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6150 } |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
6151 |
6406 | 6152 DEFUN (__go_delete__, args, , |
6153 "-*- texinfo -*-\n\ | |
6154 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ | |
6945 | 6155 Undocumented internal function.\n\ |
6406 | 6156 @end deftypefn") |
6157 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6158 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6159 |
6406 | 6160 octave_value_list retval; |
6161 | |
6162 if (args.length () == 1) | |
6163 { | |
6164 graphics_handle h = octave_NaN; | |
6165 | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
6166 const NDArray vals = args (0).array_value (); |
6406 | 6167 |
6168 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6169 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6170 // Check is all the handles to delete are valid first |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6171 // as callbacks might delete one of the handles we |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6172 // later want to delete |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6173 for (octave_idx_type i = 0; i < vals.numel (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6174 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6175 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6176 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6177 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6178 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6179 error ("delete: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6180 vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6181 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6182 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6183 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6184 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6185 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6186 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6187 for (octave_idx_type i = 0; i < vals.numel (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6188 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6189 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6190 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6191 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6192 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6193 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6194 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6195 // Don't do recursive deleting, due to callbacks |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6196 if (! obj.get_properties ().is_beingdeleted ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6197 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6198 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6199 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6200 graphics_object parent_obj = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6201 gh_manager::get_object (parent_h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6202 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6203 // NOTE: free the handle before removing it from its |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6204 // parent's children, such that the object's |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6205 // state is correct when the deletefcn callback |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6206 // is executed |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6207 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6208 gh_manager::free (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6209 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6210 // A callback function might have already deleted |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6211 // the parent |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6212 if (parent_obj.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6213 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6214 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6215 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6216 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6217 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6218 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6219 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6220 } |
6406 | 6221 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6222 error ("delete: invalid graphics object"); |
6406 | 6223 } |
6224 else | |
6225 print_usage (); | |
6226 | |
6227 return retval; | |
6228 } | |
6229 | |
6230 DEFUN (__go_axes_init__, args, , | |
6231 "-*- texinfo -*-\n\ | |
6232 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ | |
6945 | 6233 Undocumented internal function.\n\ |
6406 | 6234 @end deftypefn") |
6235 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6236 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6237 |
6406 | 6238 octave_value retval; |
6239 | |
6240 int nargin = args.length (); | |
6241 | |
6242 std::string mode = ""; | |
6243 | |
6244 if (nargin == 2) | |
6245 { | |
6246 mode = args(1).string_value (); | |
6247 | |
6248 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6249 return retval; |
6406 | 6250 } |
6251 | |
6252 if (nargin == 1 || nargin == 2) | |
6253 { | |
6254 graphics_handle h = octave_NaN; | |
6255 | |
6256 double val = args(0).double_value (); | |
6257 | |
6258 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6259 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6260 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6261 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6262 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6263 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6264 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6265 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6266 obj.set_defaults (mode); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6267 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6268 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6269 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6270 error ("__go_axes_init__: axis deleted during initialization (= %g)", val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6271 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6272 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6273 error ("__go_axes_init__: invalid graphics object (= %g)", val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6274 } |
6406 | 6275 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6276 error ("__go_axes_init__: invalid graphics object"); |
6406 | 6277 } |
6278 else | |
6279 print_usage (); | |
6280 | |
6281 return retval; | |
6282 } | |
6283 | |
6284 DEFUN (__go_handles__, , , | |
6285 "-*- texinfo -*-\n\ | |
6286 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ | |
6945 | 6287 Undocumented internal function.\n\ |
6406 | 6288 @end deftypefn") |
6289 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6290 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6291 |
6425 | 6292 return octave_value (gh_manager::handle_list ()); |
6293 } | |
6294 | |
6295 DEFUN (__go_figure_handles__, , , | |
6296 "-*- texinfo -*-\n\ | |
6297 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ | |
6945 | 6298 Undocumented internal function.\n\ |
6425 | 6299 @end deftypefn") |
6300 { | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6301 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6302 |
6425 | 6303 return octave_value (gh_manager::figure_handle_list ()); |
6406 | 6304 } |
6305 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6306 DEFUN (__go_execute_callback__, args, , |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6307 "-*- texinfo -*-\n\ |
10840 | 6308 @deftypefn {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name})\n\ |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6309 @deftypefnx {Built-in Function} {} __go_execute_callback__ (@var{h}, @var{name}, @var{param})\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6310 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6311 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6312 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6313 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6314 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6315 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6316 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6317 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6318 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6319 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6320 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6321 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6322 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6323 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6324 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6325 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6326 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6327 std::string name = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6328 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6329 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6331 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6332 gh_manager::execute_callback (h, name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6333 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6334 gh_manager::execute_callback (h, name, args(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6335 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6336 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6337 error ("__go_execute_callback__: invalid callback name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6338 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6339 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6340 error ("__go_execute_callback__: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6341 val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6342 } |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6343 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6344 error ("__go_execute_callback__: invalid graphics object"); |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6345 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6346 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6347 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6348 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6349 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6350 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
6351 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6352 DEFUN (__image_pixel_size__, args, , |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6353 "-*- texinfo -*-\n\ |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6354 @deftypefn {Built-in Function} {@var{px},@var{py}} __image_pixel_size__ (@var{h})\n\ |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6355 Internal function: returns the pixel size of the image in normalized units.\n\ |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6356 @end deftypefn") |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6357 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6358 octave_value retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6359 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6360 int nargin = args.length (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6361 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6362 if (nargin == 1) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6363 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6364 double h = args(0).double_value (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6365 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6366 if (! error_state) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6367 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6368 graphics_object fobj = gh_manager::get_object (h); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6369 if (fobj && fobj.isa ("image")) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6370 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6371 image::properties& ip = |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6372 dynamic_cast<image::properties&> (fobj.get_properties ()); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6373 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6374 Matrix dp = Matrix (1, 2, 0); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6375 dp(0, 0) = ip.pixel_xsize (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6376 dp(0, 1) = ip.pixel_ysize (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6377 retval = dp; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6378 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6379 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6380 error ("__image_pixel_size__: object is not an image"); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6381 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6382 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6383 error ("__image_pixel_size__: argument is not a handle"); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6384 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6385 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6386 print_usage (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6387 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6388 return retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6389 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
6390 |
7924 | 6391 DEFUN (available_backends, , , |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6392 "-*- texinfo -*-\n\ |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6393 @deftypefn {Built-in Function} {} available_backends ()\n\ |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6394 Return a cell array of registered graphics backends.\n\ |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6395 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6396 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6397 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6398 |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6399 return octave_value (graphics_backend::available_backends_list ()); |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6400 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
6401 |
7408 | 6402 DEFUN (drawnow, args, , |
6403 "-*- texinfo -*-\n\ | |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6404 @deftypefn {Built-in Function} {} drawnow ()\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6405 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6406 @deftypefnx {Built-in Function} {} drawnow (@var{term}, @var{file}, @var{mono}, @var{debug_file})\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6407 Update figure windows and their children. The event queue is flushed and\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6408 any callbacks generated are executed. With the optional argument\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6409 @code{\"expose\"}, only graphic objects are updated and no other events or\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6410 callbacks are processed.\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6411 The third calling form of @code{drawnow} is for debugging and is\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
6412 undocumented.\n\ |
7408 | 6413 @end deftypefn") |
6414 { | |
6415 static int drawnow_executing = 0; | |
6416 static bool __go_close_all_registered__ = false; | |
6417 | |
6418 octave_value retval; | |
6419 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6420 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6421 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6422 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6423 frame.protect_var (Vdrawnow_requested, false); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6424 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6425 frame.protect_var (drawnow_executing); |
7409 | 6426 |
6427 if (++drawnow_executing <= 1) | |
7408 | 6428 { |
7409 | 6429 if (! __go_close_all_registered__) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6430 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6431 octave_add_atexit_function ("__go_close_all__"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6432 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6433 __go_close_all_registered__ = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6434 } |
7409 | 6435 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6436 if (args.length () == 0 || args.length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6437 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6438 Matrix hlist = gh_manager::figure_handle_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6439 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6440 for (int i = 0; ! error_state && i < hlist.length (); i++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6441 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6442 graphics_handle h = gh_manager::lookup (hlist(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6443 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6444 if (h.ok () && h != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6445 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6446 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6447 figure::properties& fprops = dynamic_cast <figure::properties&> (go.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6448 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6449 if (fprops.is_modified ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6450 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6451 if (fprops.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6452 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6453 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6454 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6455 fprops.get_backend ().redraw_figure (go); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6456 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6457 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6458 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6459 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6460 fprops.set_modified (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6461 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6462 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6463 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6464 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6465 bool do_events = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6466 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6467 if (args.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6468 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6469 caseless_str val (args(0).string_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6470 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6471 if (! error_state && val.compare ("expose")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6472 do_events = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6473 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6474 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6475 error ("drawnow: invalid argument, expected `expose' as argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6476 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6477 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6478 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6479 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6480 if (do_events) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6481 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6482 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6483 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6484 gh_manager::process_events (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6485 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6486 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6487 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6488 } |
7409 | 6489 else if (args.length () >= 2 && args.length () <= 4) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6490 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6491 std::string term, file, debug_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6492 bool mono; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6493 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6494 term = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6495 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6496 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6497 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6498 file = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6499 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6500 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6501 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6502 size_t pos = file.find_last_of (file_ops::dir_sep_chars ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6503 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6504 if (pos != std::string::npos) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6505 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6506 std::string dirname = file.substr (0, pos+1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6507 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6508 file_stat fs (dirname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6509 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6510 if (! (fs && fs.is_dir ())) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6511 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6512 error ("drawnow: nonexistent directory `%s'", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6513 dirname.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6514 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6515 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6516 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6517 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6518 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6519 mono = (args.length () >= 3 ? args(2).bool_value () : false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6520 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6521 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6522 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6523 debug_file = (args.length () > 3 ? args(3).string_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6524 : ""); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6525 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6526 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6527 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6528 graphics_handle h = gcf (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6529 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6530 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6531 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6532 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6533 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6534 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6535 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6536 go.get_backend () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6537 .print_figure (go, term, file, mono, debug_file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6538 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6539 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6540 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6541 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6542 error ("drawnow: nothing to draw"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6543 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6544 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6545 error ("drawnow: invalid debug_file, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6546 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6547 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6548 error ("drawnow: invalid colormode, expected a boolean value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6549 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6550 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6551 error ("drawnow: invalid file, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6552 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6553 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6554 error ("drawnow: invalid terminal, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6555 } |
7408 | 6556 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6557 print_usage (); |
7408 | 6558 } |
7409 | 6559 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6560 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6561 |
7408 | 6562 return retval; |
6563 } | |
6564 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6565 DEFUN (addlistener, args, , |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6566 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6567 @deftypefn {Built-in Function} {} addlistener (@var{h}, @var{prop}, @var{fcn})\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6568 Register @var{fcn} as listener for the property @var{prop} of the graphics\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6569 object @var{h}. Property listeners are executed (in order of registration)\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6570 when the property is set. The new value is already available when the\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6571 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6572 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6573 @var{prop} must be a string naming a valid property in @var{h}.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6574 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6575 @var{fcn} can be a function handle, a string or a cell array whose first\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6576 element is a function handle. If @var{fcn} is a function handle, the\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6577 corresponding function should accept at least 2 arguments, that will be\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6578 set to the object handle and the empty matrix respectively. If @var{fcn}\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6579 is a string, it must be any valid octave expression. If @var{fcn} is a cell\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6580 array, the first element must be a function handle with the same signature\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6581 as described above. The next elements of the cell array are passed\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6582 as additional arguments to the function.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6583 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6584 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6585 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6586 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6587 @group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6588 function my_listener (h, dummy, p1)\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6589 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6590 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6591 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
6592 addlistener (gcf, \"position\", @{@@my_listener, \"my string\"@})\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6593 @end group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6594 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6595 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6596 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6597 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6598 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6599 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6600 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6601 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6602 if (args.length () == 3) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6603 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6604 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6605 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6606 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6607 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6608 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6609 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6610 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6611 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6612 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6613 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6614 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6615 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6616 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6617 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6618 go.add_property_listener (pname, args(2), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6619 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6620 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6621 error ("addlistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6622 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6623 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6624 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6625 error ("addlistener: invalid property name, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6626 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6627 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6628 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6629 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6630 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6631 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6632 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6633 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6634 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
6635 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6636 DEFUN (dellistener, args, , |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6637 "-*- texinfo -*-\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6638 @deftypefn {Built-in Function} {} dellistener (@var{h}, @var{prop}, @var{fcn})\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6639 Remove the registration of @var{fcn} as a listener for the property\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6640 @var{prop} of the graphics object @var{h}. The function @var{fcn} must\n\ |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6641 be the same variable (not just the same value), as was passed to the\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6642 original call to @code{addlistener}.\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6643 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6644 If @var{fcn} is not defined then all listener functions of @var{prop}\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6645 are removed.\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6646 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6647 Example:\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6648 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6649 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6650 @group\n\ |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6651 function my_listener (h, dummy, p1)\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6652 fprintf (\"my_listener called with p1=%s\\n\", p1);\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6653 endfunction\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6654 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6655 c = @{@@my_listener, \"my string\"@};\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6656 addlistener (gcf, \"position\", c);\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6657 dellistener (gcf, \"position\", c);\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6658 @end group\n\ |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6659 @end example\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6660 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6661 @end deftypefn") |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6662 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6663 gh_manager::autolock guard; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6664 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6665 octave_value retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6666 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6667 if (args.length () == 3 || args.length () == 2) |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6668 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6669 double h = args(0).double_value (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6670 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6671 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6672 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6673 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6674 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6675 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6676 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6677 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6678 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6679 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6680 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6681 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6682 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6683 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6684 go.delete_property_listener (pname, octave_value (), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6685 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6686 go.delete_property_listener (pname, args(2), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6687 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6688 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6689 error ("dellistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6690 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6691 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6692 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6693 error ("dellistener: invalid property name, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6694 } |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6695 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6696 error ("dellistener: invalid handle"); |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6697 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6698 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6699 print_usage (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6700 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6701 return retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6702 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
6703 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6704 DEFUN (addproperty, args, , |
7869 | 6705 "-*- texinfo -*-\n\ |
6706 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type}, [@var{arg}, @dots{}])\n\ | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6707 Create a new property named @var{name} in graphics object @var{h}.\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6708 @var{type} determines the type of the property to create. @var{args}\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6709 usually contains the default value of the property, but additional\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6710 arguments might be given, depending on the type of the property.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6711 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6712 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6713 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6714 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6715 @item string\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6716 A string property. @var{arg} contains the default string value.\n\ |
10840 | 6717 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6718 @item any\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6719 An un-typed property. This kind of property can hold any octave\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6720 value. @var{args} contains the default value.\n\ |
10840 | 6721 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6722 @item radio\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6723 A string property with a limited set of accepted values. The first\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6724 argument must be a string with all accepted values separated by\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6725 a vertical bar ('|'). The default value can be marked by enclosing\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6726 it with a '@{' '@}' pair. The default value may also be given as\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6727 an optional second string argument.\n\ |
10840 | 6728 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6729 @item boolean\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6730 A boolean property. This property type is equivalent to a radio\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6731 property with \"on|off\" as accepted values. @var{arg} contains\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6732 the default property value.\n\ |
10840 | 6733 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6734 @item double\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6735 A scalar double property. @var{arg} contains the default value.\n\ |
10840 | 6736 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6737 @item handle\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6738 A handle property. This kind of property holds the handle of a\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6739 graphics object. @var{arg} contains the default handle value.\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6740 When no default value is given, the property is initialized to\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6741 the empty matrix.\n\ |
10840 | 6742 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6743 @item data\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6744 A data (matrix) property. @var{arg} contains the default data\n\ |
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6745 value. When no default value is given, the data is initialized to\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6746 the empty matrix.\n\ |
10840 | 6747 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6748 @item color\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6749 A color property. @var{arg} contains the default color value.\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6750 When no default color is given, the property is set to black.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6751 An optional second string argument may be given to specify an\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6752 additional set of accepted string values (like a radio property).\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6753 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6754 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6755 @var{type} may also be the concatenation of a core object type and\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6756 a valid property name for that object type. The property created\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6757 then has the same characteristics as the referenced property (type,\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
6758 possible values, hidden state@dots{}). This allows to clone an existing\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6759 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6760 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6761 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6762 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6763 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6764 @group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6765 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6766 addproperty (\"my_radio\", gcf, \"radio\", \"val_1|val_2|@{val_3@}\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6767 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
6768 @end group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6769 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6770 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6771 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6772 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6773 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6774 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6775 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6776 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6777 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6778 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6779 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6780 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6781 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6782 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6783 double h = args(1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6784 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6785 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6786 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6787 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6788 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6789 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6790 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6791 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6792 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6793 std::string type = args(2).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6794 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6795 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6796 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6797 if (! go.get_properties ().has_property (name)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6798 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6799 property p = property::create (name, gh, type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6800 args.splice (0, 3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6801 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6802 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6803 go.get_properties ().insert_property (name, p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6804 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6805 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6806 error ("addproperty: a `%s' property already exists in the graphics object", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6807 name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6808 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6809 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6810 error ("addproperty: invalid property type, expected a string value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6811 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6812 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6813 error ("addproperty: invalid graphics object (= %g)", h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6814 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6815 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6816 error ("addproperty: invalid handle value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6817 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6818 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6819 error ("addproperty: invalid property name, expected a string value"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6820 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6821 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6822 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6823 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6824 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6825 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
6826 |
6595 | 6827 octave_value |
7447 | 6828 get_property_from_handle (double handle, const std::string& property, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6829 const std::string& func) |
6595 | 6830 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6831 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6832 |
6595 | 6833 graphics_object obj = gh_manager::get_object (handle); |
6834 octave_value retval; | |
6835 | |
6836 if (obj) | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
6837 retval = obj.get (caseless_str (property)); |
6595 | 6838 else |
6839 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
6840 | |
6841 return retval; | |
6842 } | |
6843 | |
6844 bool | |
7447 | 6845 set_property_in_handle (double handle, const std::string& property, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6846 const octave_value& arg, const std::string& func) |
6595 | 6847 { |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6848 gh_manager::autolock guard; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
6849 |
6595 | 6850 graphics_object obj = gh_manager::get_object (handle); |
6851 int ret = false; | |
6852 | |
6853 if (obj) | |
6854 { | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
6855 obj.set (caseless_str (property), arg); |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
6856 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
6857 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6858 ret = true; |
6595 | 6859 } |
6860 else | |
6861 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
6862 | |
6863 return ret; | |
6864 } |