Mercurial > hg > octave-lyh
annotate src/graphics.cc @ 13757:1e81e2e30af3
default limits for logscale plots
* graphics.cc (default_lim): New optional argument, logscale.
Return [0.1, 1.0] if logscale is true.
(axes::properties::get_axis_limits): Return default limits if min/max
values are at their initial values.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 26 Oct 2011 17:36:54 -0400 |
parents | 6dfebfa334cb |
children | 760e4e88dba3 |
rev | line source |
---|---|
6406 | 1 /* |
2 | |
11523 | 3 Copyright (C) 2007-2011 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" |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
48 #include "oct-locbuf.h" |
6705 | 49 #include "oct-obj.h" |
50 #include "oct-map.h" | |
51 #include "ov-fcn-handle.h" | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
52 #include "pager.h" |
6705 | 53 #include "parse.h" |
7409 | 54 #include "toplev.h" |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
55 #include "txt-eng-ft.h" |
7222 | 56 #include "unwind-prot.h" |
6595 | 57 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
58 // 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
|
59 static octave_value xget (const graphics_handle& h, const caseless_str& name); |
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 | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
223 default_lim (bool logscale = false) |
7363 | 224 { |
225 Matrix m (1, 2, 0); | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
226 |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
227 if (logscale) |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
228 { |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
229 m(0) = 0.1; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
230 m(1) = 1.0; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
231 } |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
232 else |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
233 m(1) = 1; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
234 |
7363 | 235 return m; |
236 } | |
237 | |
238 static Matrix | |
239 default_data (void) | |
240 { | |
241 Matrix retval (1, 2); | |
242 | |
243 retval(0) = 0; | |
244 retval(1) = 1; | |
245 | |
246 return retval; | |
247 } | |
248 | |
7427 | 249 static Matrix |
250 default_axes_position (void) | |
251 { | |
252 Matrix m (1, 4, 0.0); | |
253 m(0) = 0.13; | |
254 m(1) = 0.11; | |
255 m(2) = 0.775; | |
256 m(3) = 0.815; | |
257 return m; | |
258 } | |
259 | |
260 static Matrix | |
261 default_axes_outerposition (void) | |
262 { | |
263 Matrix m (1, 4, 0.0); | |
264 m(2) = m(3) = 1.0; | |
265 return m; | |
266 } | |
267 | |
7445 | 268 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
269 default_axes_tick (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
270 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
271 Matrix m (1, 6, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
272 m(0) = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
273 m(1) = 0.2; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
274 m(2) = 0.4; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
275 m(3) = 0.6; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
276 m(4) = 0.8; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
277 m(5) = 1.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
278 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
279 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
280 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
281 static Matrix |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
282 default_axes_ticklength (void) |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
283 { |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
284 Matrix m (1, 2, 0.01); |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
285 m(1) = 0.025; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
286 return m; |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
287 } |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
288 |
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
289 static Matrix |
7445 | 290 default_figure_position (void) |
291 { | |
292 Matrix m (1, 4, 0.0); | |
293 m(0) = 300; | |
294 m(1) = 200; | |
295 m(2) = 560; | |
296 m(3) = 420; | |
297 return m; | |
298 } | |
299 | |
7427 | 300 static Matrix |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
301 default_figure_papersize (void) |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
302 { |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
303 Matrix m (1, 2, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
304 m(0) = 8.5; |
8961
6b87f2f34fdd
graphics.cc: Fix default "papersize" property value.
Ben Abbott <bpabbott@mac.com>
parents:
8944
diff
changeset
|
305 m(1) = 11.0; |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
306 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
307 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
308 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
309 static Matrix |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
310 default_figure_paperposition (void) |
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 Matrix m (1, 4, 0.0); |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
313 m(0) = 0.25; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
314 m(1) = 2.50; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
315 m(2) = 8.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
316 m(3) = 6.00; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
317 return m; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
318 } |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
319 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
320 static Matrix |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
321 default_control_position (void) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
322 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
323 Matrix retval (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
324 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
325 retval(0) = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
326 retval(1) = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
327 retval(2) = 80; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
328 retval(3) = 30; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
329 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
330 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
331 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
332 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
333 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
334 default_control_sliderstep (void) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
335 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
336 Matrix retval (1, 2, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
337 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
338 retval(0) = 0.01; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
339 retval(1) = 0.1; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
340 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
341 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
342 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
343 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
344 static Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
345 default_panel_position (void) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
346 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
347 Matrix retval (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
348 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
349 retval(0) = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
350 retval(1) = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
351 retval(2) = retval(3) = 0.5; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
352 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
353 return retval; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
354 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
355 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
356 static double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
357 convert_font_size (double font_size, const caseless_str& from_units, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
358 const caseless_str& to_units, double parent_height = 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
359 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
360 // Simple case where from_units == to_units |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
361 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
362 if (from_units.compare (to_units)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
363 return font_size; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
364 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
365 // Converts the given fontsize using the following transformation: |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
366 // <old_font_size> => points => <new_font_size> |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
367 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
368 double points_size = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
369 double res = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
370 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
371 if (from_units.compare ("points")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
372 points_size = font_size; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
373 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
374 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
375 res = xget (0, "screenpixelsperinch").double_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
376 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
377 if (from_units.compare ("pixels")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
378 points_size = font_size * 72.0 / res; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
379 else if (from_units.compare ("inches")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
380 points_size = font_size * 72.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
381 else if (from_units.compare ("centimeters")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
382 points_size = font_size * 72.0 / 2.54; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
383 else if (from_units.compare ("normalized")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
384 points_size = font_size * parent_height * 72.0 / res; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
385 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
386 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
387 double new_font_size = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
388 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
389 if (to_units.compare ("points")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
390 new_font_size = points_size; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
391 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
392 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
393 if (res <= 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
394 res = xget (0, "screenpixelsperinch").double_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
395 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
396 if (to_units.compare ("pixels")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
397 new_font_size = points_size * res / 72.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
398 else if (to_units.compare ("inches")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
399 new_font_size = points_size / 72.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
400 else if (to_units.compare ("centimeters")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
401 new_font_size = points_size * 2.54 / 72.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
402 else if (to_units.compare ("normalized")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
403 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
404 // Avoid setting font size to (0/0) = NaN |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
405 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
406 if (parent_height > 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
407 new_font_size = points_size * res / (parent_height * 72.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
408 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
409 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
410 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
411 return new_font_size; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
412 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
413 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
414 static Matrix |
7427 | 415 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
|
416 const caseless_str& to_units, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
417 const Matrix& parent_dim = Matrix (1, 2, 0.0)) |
7427 | 418 { |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
419 Matrix retval (1, pos.numel ()); |
7427 | 420 double res = 0; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
421 bool is_rectangle = (pos.numel () == 4); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
422 bool is_2d = (pos.numel () == 2); |
7427 | 423 |
424 if (from_units.compare ("pixels")) | |
425 retval = pos; | |
426 else if (from_units.compare ("normalized")) | |
427 { | |
428 retval(0) = pos(0) * parent_dim(0) + 1; | |
429 retval(1) = pos(1) * parent_dim(1) + 1; | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
430 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
431 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
432 retval(2) = pos(2) * parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
433 retval(3) = pos(3) * parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
434 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
435 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
436 retval(2) = 0; |
7427 | 437 } |
438 else if (from_units.compare ("characters")) | |
439 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
440 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
441 res = xget (0, "screenpixelsperinch").double_value (); |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
442 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
443 double f = 0.0; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
444 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
445 // FIXME -- this assumes the system font is Helvetica 10pt |
8599
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
446 // (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
|
447 f = 12.0 * res / 74.951; |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
448 |
b4fb0a52b15e
Improve default property compatibility.
Ben Abbott <bpabbott@mac.com>
parents:
8560
diff
changeset
|
449 if (f > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
450 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
451 retval(0) = 0.5 * pos(0) * f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
452 retval(1) = pos(1) * f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
453 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
454 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
455 retval(2) = 0.5 * pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
456 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
457 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
458 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
459 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
460 } |
7427 | 461 } |
462 else | |
463 { | |
9238
0ae2b6617005
Use display information from the root object to compute bounding boxes
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9185
diff
changeset
|
464 if (res <= 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
465 res = xget (0, "screenpixelsperinch").double_value (); |
7427 | 466 |
467 double f = 0.0; | |
468 | |
469 if (from_units.compare ("points")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
470 f = res / 72.0; |
7427 | 471 else if (from_units.compare ("inches")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
472 f = res; |
7427 | 473 else if (from_units.compare ("centimeters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
474 f = res / 2.54; |
7427 | 475 |
476 if (f > 0) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
477 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
478 retval(0) = pos(0) * f + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
479 retval(1) = pos(1) * f + 1; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
480 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
481 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
482 retval(2) = pos(2) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
483 retval(3) = pos(3) * f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
484 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
485 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
486 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
487 } |
7427 | 488 } |
489 | |
490 if (! to_units.compare ("pixels")) | |
491 { | |
492 if (to_units.compare ("normalized")) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
493 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
494 retval(0) = (retval(0) - 1) / parent_dim(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
495 retval(1) = (retval(1) - 1) / parent_dim(1); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
496 if (is_rectangle) |
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 retval(2) /= parent_dim(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
499 retval(3) /= parent_dim(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
500 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
501 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
502 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
503 } |
7427 | 504 else if (to_units.compare ("characters")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
505 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
506 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
507 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
508 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
509 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
510 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
511 f = 12.0 * res / 74.951; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
512 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
513 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
514 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
515 retval(0) = 2 * retval(0) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
516 retval(1) = retval(1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
517 if (is_rectangle) |
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 retval(2) = 2 * retval(2) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
520 retval(3) = retval(3) / f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
521 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
522 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
523 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
524 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
525 } |
7427 | 526 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
527 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
528 if (res <= 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
529 res = xget (0, "screenpixelsperinch").double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
530 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
531 double f = 0.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
532 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
533 if (to_units.compare ("points")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
534 f = res / 72.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
535 else if (to_units.compare ("inches")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
536 f = res; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
537 else if (to_units.compare ("centimeters")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
538 f = res / 2.54; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
539 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
540 if (f > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
541 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
542 retval(0) = (retval(0) - 1) / f; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
543 retval(1) = (retval(1) - 1) / f; |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
544 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
545 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
546 retval(2) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
547 retval(3) /= f; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
548 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
549 else if (! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
550 retval(2) = 0; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
551 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
552 } |
7427 | 553 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
554 else if (! is_rectangle && ! is_2d) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
555 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
556 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
557 return retval; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
558 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
559 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
560 static Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
561 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
|
562 const caseless_str& from_units, |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
563 const caseless_str& to_units) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
564 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
565 graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
566 graphics_object ax = go.get_ancestor ("axes"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
567 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
568 Matrix retval (1, pos.numel (), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
569 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
570 if (ax.valid_object ()) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
571 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
572 const axes::properties& ax_props = |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
573 dynamic_cast<const axes::properties&> (ax.get_properties ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
574 graphics_xform ax_xform = ax_props.get_transform (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
575 bool is_rectangle = (pos.numel () == 4); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
576 Matrix ax_bbox = ax_props.get_boundingbox (true), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
577 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
|
578 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
579 if (from_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
580 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
581 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
582 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
583 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
|
584 v2 = ax_xform.transform (pos(0) + pos(2), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
585 pos(1) + pos(3), 0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
586 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
587 retval(0) = v1(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
588 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
|
589 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
590 retval(3) = v1(1) - v2(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
591 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
592 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
593 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
594 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
|
595 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
596 retval(0) = v(0) - ax_bbox(0) + 1; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
597 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
|
598 retval(2) = 0; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
599 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
600 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
601 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
602 retval = convert_position (pos, from_units, "pixels", ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
603 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
604 if (! to_units.compare ("pixels")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
605 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
606 if (to_units.compare ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
607 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
608 if (is_rectangle) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
609 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
610 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
|
611 ax_bbox(1) + ax_bbox(3) - retval(1) + 1), |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
612 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
|
613 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
|
614 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
615 retval(0) = v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
616 retval(1) = v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
617 retval(2) = v2(0) - v1(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
618 retval(3) = v2(1) - v1(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
619 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
620 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
621 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
622 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
|
623 ax_bbox(1) + ax_bbox(3) - retval(1) + 1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
624 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
625 retval(0) = v(0); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
626 retval(1) = v(1); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
627 retval(2) = v(2); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
628 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
629 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
630 else |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
631 retval = convert_position (retval, "pixels", to_units, ax_size); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
632 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
633 } |
7427 | 634 |
635 return retval; | |
636 } | |
637 | |
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
|
638 // 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
|
639 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
|
640 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
|
641 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
642 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
|
643 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
|
644 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
|
645 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
646 |
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
|
647 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
|
648 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
|
649 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
|
650 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
|
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 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
|
653 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
|
654 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
|
655 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
|
656 |
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 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
|
658 { |
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 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
|
660 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
|
661 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
|
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 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
|
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 (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
|
666 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
|
667 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
|
668 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
|
669 |
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 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
|
671 |
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 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
|
673 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
|
674 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
|
675 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
676 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
677 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 { |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
684 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
|
685 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
|
686 } |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
687 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
688 static octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
689 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
|
690 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
|
691 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
692 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
|
693 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
694 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
|
695 return cdata; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
696 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
697 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
|
698 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
|
699 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
700 graphics_object go = gh_manager::get_object (props.get___myhandle__ ()); |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
701 graphics_object fig = go.get_ancestor ("figure"); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
702 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
703 if (fig.valid_object ()) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
704 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
705 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
|
706 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
707 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
708 cmap = _cmap; |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
709 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
710 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
711 if (is_scaled) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
712 { |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
713 graphics_object ax = go.get_ancestor ("axes"); |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
714 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
715 if (ax.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
716 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
717 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
|
718 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
719 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
720 clim = _clim; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
721 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
722 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
723 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
724 dv.resize (cdim); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
725 dv(cdim-1) = 3; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
726 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
727 NDArray a (dv); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
728 |
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
|
729 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
|
730 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
|
731 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
732 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
|
733 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
|
734 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
735 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
|
736 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
|
737 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
738 #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
|
739 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
|
740 { \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
741 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
|
742 \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
743 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
|
744 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
|
745 } \ |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
746 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
|
747 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 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
|
754 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
|
755 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
|
756 |
4c1ffaed8caa
graphics.cc (convert_cdata): avoid data conversion for entire cdata array at once
John W. Eaton <jwe@octave.org>
parents:
10922
diff
changeset
|
757 #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
|
758 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
759 return octave_value (a); |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
760 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
761 |
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
|
762 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
|
763 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
|
764 get_array_limits (const Array<T>& m, double& emin, double& emax, |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
765 double& eminp, double& emaxp) |
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
|
766 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
767 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
|
768 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
|
769 |
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
|
770 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
|
771 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
772 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
|
773 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
774 // Don't need to test for NaN here as NaN>x and NaN<x is always false |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
775 if (! xisinf (e)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
776 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
777 if (e < emin) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
778 emin = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
779 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
780 if (e > emax) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
781 emax = e; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
782 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
783 if (e > 0 && e < eminp) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
784 eminp = e; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
785 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
786 if (e < 0 && e > emaxp) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
787 emaxp = e; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
788 } |
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
|
789 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
790 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
791 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
792 static bool |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
793 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
|
794 caseless_str& rest) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
795 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
796 int len = name.length (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
797 int offset = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
798 bool result = false; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
799 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
800 if (len >= 4) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
801 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
802 caseless_str pfx = name.substr (0, 4); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
803 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
804 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
805 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
806 offset = 4; |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
807 else if (len >= 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
808 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
809 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
810 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
811 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
812 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
813 else if (len >= 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
814 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
815 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
816 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
817 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
818 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
819 else if (len >= 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
820 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
821 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
822 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
823 if (pfx.compare ("surface") || pfx.compare ("hggroup") |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
824 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
825 offset = 7; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
826 else if (len >= 9) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
827 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
828 pfx = name.substr (0, 9); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
829 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
830 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
831 || pfx.compare ("uitoolbar")) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
832 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
833 else if (len >= 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
834 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
835 pfx = name.substr (0, 10); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
836 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
837 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
838 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
839 else if (len >= 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
840 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
841 pfx = name.substr (0, 12); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
842 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
843 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
844 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
845 else if (len >= 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
846 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
847 pfx = name.substr (0, 13); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
848 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
849 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
850 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
851 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
852 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
853 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
854 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
855 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
856 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
857 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
858 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
859 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
860 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
861 go_name = pfx; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
862 rest = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
863 result = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
864 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
865 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
866 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
867 return result; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
868 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
869 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
870 static base_graphics_object* |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
871 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
|
872 const graphics_handle& h = graphics_handle (), |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
873 const graphics_handle& p = graphics_handle ()) |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
874 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
875 base_graphics_object *go = 0; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
876 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
877 if (type.compare ("figure")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
878 go = new figure (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
879 else if (type.compare ("axes")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
880 go = new axes (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
881 else if (type.compare ("line")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
882 go = new line (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
883 else if (type.compare ("text")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
884 go = new text (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
885 else if (type.compare ("image")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
886 go = new image (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
887 else if (type.compare ("patch")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
888 go = new patch (h, p); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
889 else if (type.compare ("surface")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
890 go = new surface (h, p); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
891 else if (type.compare ("hggroup")) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
892 go = new hggroup (h, p); |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
893 else if (type.compare ("uimenu")) |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
894 go = new uimenu (h, p); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
895 else if (type.compare ("uicontrol")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
896 go = new uicontrol (h, p); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
897 else if (type.compare ("uipanel")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
898 go = new uipanel (h, p); |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
899 else if (type.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
900 go = new uicontextmenu (h, p); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
901 else if (type.compare ("uitoolbar")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
902 go = new uitoolbar (h, p); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
903 else if (type.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
904 go = new uipushtool (h, p); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
905 else if (type.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
906 go = new uitoggletool (h, p); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
907 return go; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
908 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
909 |
6406 | 910 // --------------------------------------------------------------------- |
911 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
912 bool |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
913 base_property::set (const octave_value& v, bool do_run, bool do_notify_toolkit) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
914 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
915 if (do_set (v)) |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
916 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
917 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
918 // Notify graphics toolkit. |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
919 if (id >= 0 && do_notify_toolkit) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
920 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
921 graphics_object go = gh_manager::get_object (parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
922 if (go) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
923 go.update (id); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
924 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
925 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
926 // run listeners |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
927 if (do_run && ! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
928 run_listeners (POSTSET); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
929 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
930 return true; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
931 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
932 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
933 return false; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
934 } |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
935 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
936 |
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
937 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
938 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
|
939 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
940 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
|
941 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
942 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
|
943 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
944 gh_manager::execute_listener (parent, l(i)); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
945 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
946 if (error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
947 break; |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
948 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
949 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
950 |
6705 | 951 radio_values::radio_values (const std::string& opt_string) |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
952 : default_val (), possible_vals () |
6406 | 953 { |
6705 | 954 size_t beg = 0; |
955 size_t len = opt_string.length (); | |
956 bool done = len == 0; | |
6681 | 957 |
6705 | 958 while (! done) |
959 { | |
960 size_t end = opt_string.find ('|', beg); | |
6681 | 961 |
6705 | 962 if (end == std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
963 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
964 end = len; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
965 done = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
966 } |
6681 | 967 |
6705 | 968 std::string t = opt_string.substr (beg, end-beg); |
6681 | 969 |
6705 | 970 // Might want more error checking here... |
971 if (t[0] == '{') | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
972 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
973 t = t.substr (1, t.length () - 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
974 default_val = t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
975 } |
6705 | 976 else if (beg == 0) // ensure default value |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
977 default_val = t; |
6681 | 978 |
6705 | 979 possible_vals.insert (t); |
6681 | 980 |
6705 | 981 beg = end + 1; |
982 } | |
983 } | |
6681 | 984 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
985 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
986 radio_values::values_as_string (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
987 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
988 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
989 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
|
990 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
991 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
992 if (retval == "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
993 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
994 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
995 retval = "{" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
996 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
997 retval = *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
998 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
999 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1000 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1001 if (*it == default_value ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1002 retval += " | {" + *it + "}"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1003 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1004 retval += " | " + *it; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1005 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1006 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1007 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1008 retval = "[ " + retval + " ]"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1009 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1010 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1011 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1012 Cell |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1013 radio_values::values_as_cell (void) const |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1014 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1015 octave_idx_type i = 0; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1016 Cell retval (nelem (), 1); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1017 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
|
1018 it != possible_vals.end (); it++) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1019 retval(i++) = std::string (*it); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1020 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1021 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1022 |
6705 | 1023 bool |
6761 | 1024 color_values::str2rgb (std::string str) |
6681 | 1025 { |
6705 | 1026 double tmp_rgb[3] = {0, 0, 0}; |
1027 bool retval = true; | |
6761 | 1028 unsigned int len = str.length(); |
6681 | 1029 |
6925 | 1030 std::transform (str.begin (), str.end (), str.begin (), tolower); |
1031 | |
6761 | 1032 if (str.compare(0, len, "blue", 0, len) == 0) |
1033 tmp_rgb[2] = 1; | |
7869 | 1034 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
|
1035 || str.compare(0, len, "k", 0, len) == 0) |
6761 | 1036 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 0; |
1037 else if (str.compare(0, len, "red", 0, len) == 0) | |
1038 tmp_rgb[0] = 1; | |
1039 else if (str.compare(0, len, "green", 0, len) == 0) | |
1040 tmp_rgb[1] = 1; | |
1041 else if (str.compare(0, len, "yellow", 0, len) == 0) | |
1042 tmp_rgb[0] = tmp_rgb[1] = 1; | |
1043 else if (str.compare(0, len, "magenta", 0, len) == 0) | |
1044 tmp_rgb[0] = tmp_rgb[2] = 1; | |
1045 else if (str.compare(0, len, "cyan", 0, len) == 0) | |
1046 tmp_rgb[1] = tmp_rgb[2] = 1; | |
7869 | 1047 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
|
1048 || str.compare(0, len, "w", 0, len) == 0) |
6761 | 1049 tmp_rgb[0] = tmp_rgb[1] = tmp_rgb[2] = 1; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1050 else |
6761 | 1051 retval = false; |
6406 | 1052 |
6705 | 1053 if (retval) |
1054 { | |
1055 for (int i = 0; i < 3; i++) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1056 xrgb(i) = tmp_rgb[i]; |
6705 | 1057 } |
6563 | 1058 |
6705 | 1059 return retval; |
1060 } | |
6681 | 1061 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1062 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1063 color_property::do_set (const octave_value& val) |
6790 | 1064 { |
1065 if (val.is_string ()) | |
1066 { | |
1067 std::string s = val.string_value (); | |
1068 | |
1069 if (! s.empty ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1070 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1071 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1072 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1073 if (radio_val.contains (s, match)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1074 { |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1075 if (current_type != radio_t || match != current_val) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1076 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1077 if (s.length () != match.length ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1078 warning_with_id ("Octave:abbreviated-property-match", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1079 "%s: allowing %s to match %s value %s", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1080 "set", s.c_str (), get_name ().c_str (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1081 match.c_str ()); |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1082 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1083 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1084 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1085 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1086 } |
6790 | 1087 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1088 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1089 color_values col (s); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1090 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1091 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1092 if (current_type != color_t || col != color_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1093 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1094 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1095 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1096 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1097 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1098 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1099 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1100 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
|
1101 get_name ().c_str (), s.c_str ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1102 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1103 } |
6790 | 1104 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1105 error ("invalid value for color property \"%s\"", |
7363 | 1106 get_name ().c_str ()); |
6790 | 1107 } |
9311
868fbeb2e365
allow ranges and other matrices in set
Jaroslav Hajek <highegg@gmail.com>
parents:
9238
diff
changeset
|
1108 else if (val.is_numeric_type ()) |
6790 | 1109 { |
1110 Matrix m = val.matrix_value (); | |
1111 | |
1112 if (m.numel () == 3) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1113 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1114 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
|
1115 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1116 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1117 if (current_type != color_t || col != color_val) |
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 color_val = col; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1120 current_type = color_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1121 return true; |
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 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1124 } |
6790 | 1125 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1126 error ("invalid value for color property \"%s\"", |
7363 | 1127 get_name ().c_str ()); |
6790 | 1128 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1129 else |
7363 | 1130 error ("invalid value for color property \"%s\"", |
1131 get_name ().c_str ()); | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1132 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1133 return false; |
6790 | 1134 } |
1135 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1136 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1137 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
|
1138 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1139 if (val.is_string ()) |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1140 { |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1141 std::string s = val.string_value (); |
13236
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1142 std::string match; |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1143 |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1144 if (! s.empty () && radio_val.contains (s, match)) |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1145 { |
8bb526fb3349
allow radio values for graphics properaties to be abbreviated
John W. Eaton <jwe@octave.org>
parents:
13211
diff
changeset
|
1146 if (current_type != radio_t || match != current_val) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1147 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1148 if (s.length () != match.length ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1149 warning_with_id ("Octave:abbreviated-property-match", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1150 "%s: allowing %s to match %s value %s", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1151 "set", s.c_str (), get_name ().c_str (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1152 match.c_str ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1153 current_val = match; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1154 current_type = radio_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1155 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1156 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1157 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1158 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1159 error ("invalid value for double_radio property \"%s\"", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1160 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
|
1161 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1162 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
|
1163 { |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1164 double new_dval = val.double_value (); |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1165 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1166 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
|
1167 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1168 dval = new_dval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1169 current_type = double_t; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1170 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1171 } |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1172 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1173 else |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1174 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
|
1175 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1176 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1177 return false; |
7844
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1178 } |
3d60445d3638
Add new double_radio_property class for alpha values.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7843
diff
changeset
|
1179 |
7363 | 1180 bool |
1181 array_property::validate (const octave_value& v) | |
1182 { | |
7364 | 1183 bool xok = false; |
7363 | 1184 |
8333 | 1185 // 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
|
1186 if (v.is_empty () && v.is_numeric_type ()) |
7363 | 1187 return true; |
1188 | |
1189 // check value type | |
1190 if (type_constraints.size () > 0) | |
1191 { | |
1192 for (std::list<std::string>::const_iterator it = type_constraints.begin (); | |
7364 | 1193 ! 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
|
1194 if ((*it) == v.class_name ()) |
7364 | 1195 xok = true; |
7363 | 1196 } |
1197 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
|
1198 xok = v.is_numeric_type (); |
7363 | 1199 |
7364 | 1200 if (xok) |
7363 | 1201 { |
1202 dim_vector vdims = v.dims (); | |
1203 int vlen = vdims.length (); | |
1204 | |
7364 | 1205 xok = false; |
7363 | 1206 |
1207 // check value size | |
1208 if (size_constraints.size () > 0) | |
1209 for (std::list<dim_vector>::const_iterator it = size_constraints.begin (); | |
7364 | 1210 ! xok && it != size_constraints.end (); ++it) |
7363 | 1211 { |
1212 dim_vector itdims = (*it); | |
1213 | |
1214 if (itdims.length () == vlen) | |
1215 { | |
7364 | 1216 xok = true; |
7363 | 1217 |
7364 | 1218 for (int i = 0; xok && i < vlen; i++) |
7363 | 1219 if (itdims(i) >= 0 && itdims(i) != vdims(i)) |
7364 | 1220 xok = false; |
7363 | 1221 } |
1222 } | |
1223 else | |
1224 return true; | |
1225 } | |
1226 | |
7364 | 1227 return xok; |
7363 | 1228 } |
1229 | |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1230 bool |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1231 array_property::is_equal (const octave_value& v) const |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1232 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1233 if (data.type_name () == v.type_name ()) |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1234 { |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1235 if (data.dims () == v.dims ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1236 { |
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
|
1237 |
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
|
1238 #define CHECK_ARRAY_EQUAL(T,F,A) \ |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1239 { \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1240 if (data.numel () == 1) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1241 return data.F ## scalar_value () == \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1242 v.F ## scalar_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1243 else \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1244 { \ |
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
|
1245 /* 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
|
1246 /* that are converted, to not be deallocated early */ \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1247 const A m1 = data.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1248 const T* d1 = m1.data (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1249 const A m2 = v.F ## array_value (); \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1250 const T* d2 = m2.data ();\ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1251 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1252 bool flag = true; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1253 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1254 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
|
1255 if (d1[i] != d2[i]) \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1256 flag = false; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1257 \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1258 return flag; \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1259 } \ |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1260 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1261 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1262 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
|
1263 CHECK_ARRAY_EQUAL (double, , NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1264 else if (data.is_single_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1265 CHECK_ARRAY_EQUAL (float, float_, FloatNDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1266 else if (data.is_int8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1267 CHECK_ARRAY_EQUAL (octave_int8, int8_, int8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1268 else if (data.is_int16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1269 CHECK_ARRAY_EQUAL (octave_int16, int16_, int16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1270 else if (data.is_int32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1271 CHECK_ARRAY_EQUAL (octave_int32, int32_, int32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1272 else if (data.is_int64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1273 CHECK_ARRAY_EQUAL (octave_int64, int64_, int64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1274 else if (data.is_uint8_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1275 CHECK_ARRAY_EQUAL (octave_uint8, uint8_, uint8NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1276 else if (data.is_uint16_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1277 CHECK_ARRAY_EQUAL (octave_uint16, uint16_, uint16NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1278 else if (data.is_uint32_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1279 CHECK_ARRAY_EQUAL (octave_uint32, uint32_, uint32NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1280 else if (data.is_uint64_type ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1281 CHECK_ARRAY_EQUAL (octave_uint64, uint64_, uint64NDArray) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1282 } |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1283 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1284 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1285 return false; |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1286 } |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1287 |
7363 | 1288 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
|
1289 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
|
1290 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1291 xmin = xminp = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1292 xmax = xmaxp = -octave_Inf; |
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
|
1293 |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1294 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
|
1295 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1296 if (data.is_integer_type ()) |
10315
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 if (data.is_int8_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1299 get_array_limits (data.int8_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1300 else if (data.is_uint8_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1301 get_array_limits (data.uint8_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1302 else if (data.is_int16_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1303 get_array_limits (data.int16_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1304 else if (data.is_uint16_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1305 get_array_limits (data.uint16_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1306 else if (data.is_int32_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1307 get_array_limits (data.int32_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1308 else if (data.is_uint32_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1309 get_array_limits (data.uint32_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1310 else if (data.is_int64_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1311 get_array_limits (data.int64_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1312 else if (data.is_uint64_type ()) |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1313 get_array_limits (data.uint64_array_value (), xmin, xmax, xminp, xmaxp); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1314 } |
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
|
1315 else |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
1316 get_array_limits (data.array_value (), xmin, xmax, xminp, xmaxp); |
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
|
1317 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1318 } |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
1319 |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1320 bool |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
1321 handle_property::do_set (const octave_value& v) |
7363 | 1322 { |
1323 double dv = v.double_value (); | |
1324 | |
1325 if (! error_state) | |
1326 { | |
1327 graphics_handle gh = gh_manager::lookup (dv); | |
1328 | |
1329 if (xisnan (gh.value ()) || gh.ok ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1330 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1331 if (current_val != gh) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1332 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1333 current_val = gh; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1334 return true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1335 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1336 } |
7363 | 1337 else |
1338 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
|
1339 dv, get_name ().c_str ()); |
7363 | 1340 } |
1341 else | |
1342 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
|
1343 get_name ().c_str ()); |
8063
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1344 |
41bc700ff642
Trigger actions/listeners only for actual property change
Michael Goffioul
parents:
8062
diff
changeset
|
1345 return false; |
7363 | 1346 } |
1347 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1348 Matrix |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1349 children_property::do_get_children (bool return_hidden) const |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1350 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1351 Matrix retval (children_list.size (), 1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1352 octave_idx_type k = 0; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1353 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1354 graphics_object go = gh_manager::get_object (0); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1355 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1356 root_figure::properties& props = |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1357 dynamic_cast<root_figure::properties&> (go.get_properties ()); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1358 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1359 if (! props.is_showhiddenhandles ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1360 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1361 for (const_children_list_iterator p = children_list.begin (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1362 p != children_list.end (); p++) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1363 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1364 graphics_handle kid = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1365 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1366 if (gh_manager::is_handle_visible (kid)) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1367 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1368 if (! return_hidden) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1369 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1370 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1371 else if (return_hidden) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1372 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1373 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1374 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1375 retval.resize (k, 1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1376 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1377 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1378 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1379 for (const_children_list_iterator p = children_list.begin (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1380 p != children_list.end (); p++) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1381 retval(k++) = *p; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1382 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1383 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1384 return retval; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1385 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1386 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1387 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1388 children_property::do_delete_children (bool clear) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1389 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1390 for (children_list_iterator p = children_list.begin (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1391 p != children_list.end (); p++) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1392 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1393 graphics_object go = gh_manager::get_object (*p); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1394 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1395 if (go.valid_object ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1396 gh_manager::free (*p); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1397 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1398 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1399 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1400 if (clear) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1401 children_list.clear (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1402 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
1403 |
7363 | 1404 bool |
7367 | 1405 callback_property::validate (const octave_value& v) const |
7363 | 1406 { |
7367 | 1407 // case 1: function handle |
1408 // case 2: cell array with first element being a function handle | |
1409 // case 3: string corresponding to known function name | |
1410 // case 4: evaluatable string | |
1411 // case 5: empty matrix | |
1412 | |
1413 if (v.is_function_handle ()) | |
1414 return true; | |
1415 else if (v.is_string ()) | |
1416 // complete validation will be done at execution-time | |
1417 return true; | |
1418 else if (v.is_cell () && v.length () > 0 | |
1419 && (v.rows() == 1 || v.columns () == 1) | |
1420 && v.cell_value ()(0).is_function_handle ()) | |
1421 return true; | |
1422 else if (v.is_empty ()) | |
1423 return true; | |
1424 | |
1425 return false; | |
7363 | 1426 } |
1427 | |
13324
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1428 // If TRUE, we are executing any callback function, or the functions it |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1429 // calls. Used to determine handle visibility inside callback |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1430 // functions. |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1431 static bool executing_callback = false; |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1432 |
7363 | 1433 void |
7367 | 1434 callback_property::execute (const octave_value& data) const |
7363 | 1435 { |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1436 unwind_protect frame; |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1437 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1438 // We are executing the callback function associated with this |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1439 // callback property. When set to true, we avoid recursive calls to |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1440 // callback routines. |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1441 frame.protect_var (executing); |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1442 |
13324
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1443 // We are executing a callback function, so allow handles that have |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1444 // their handlevisibility property set to "callback" to be visible. |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1445 frame.protect_var (executing_callback); |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1446 |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1447 if (! executing) |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1448 { |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1449 executing = true; |
13324
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
1450 executing_callback = true; |
13323
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1451 |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1452 if (callback.is_defined () && ! callback.is_empty ()) |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1453 gh_manager::execute_callback (get_parent (), callback, data); |
de081abd32c6
don't execute graphics handle callback functions recursively
John W. Eaton <jwe@octave.org>
parents:
13281
diff
changeset
|
1454 } |
7824
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1455 } |
adb520646d7e
Fix execution of callback strings and allow execution of callback by name.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7822
diff
changeset
|
1456 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1457 // Used to cache dummy graphics objects from which dynamic |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1458 // properties can be cloned. |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1459 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
|
1460 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1461 property |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1462 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
|
1463 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
|
1464 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1465 property retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1466 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1467 if (type.compare ("string")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1468 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1469 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
|
1470 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1471 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1472 retval = property (new string_property (name, h, val)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1473 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1474 else if (type.compare ("any")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1475 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1476 octave_value val = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1477 (args.length () > 0 ? args(0) : octave_value (Matrix ())); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1478 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1479 retval = property (new any_property (name, h, val)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1480 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1481 else if (type.compare ("radio")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1482 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1483 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1484 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1485 std::string vals = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1486 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1487 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1488 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1489 retval = property (new radio_property (name, h, vals)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1490 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1491 if (args.length () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1492 retval.set (args(1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1493 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1494 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1495 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
|
1496 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1497 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1498 error ("addproperty: missing possible values for radio property"); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1499 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1500 else if (type.compare ("double")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1501 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1502 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
|
1503 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1504 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1505 retval = property (new double_property (name, h, d)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1506 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1507 else if (type.compare ("handle")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1508 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1509 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
|
1510 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1511 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1512 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1513 graphics_handle gh (hh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1514 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1515 retval = property (new handle_property (name, h, gh)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1516 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1517 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1518 else if (type.compare ("boolean")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1519 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1520 retval = property (new bool_property (name, h, false)); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1521 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1522 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1523 retval.set (args(0)); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1524 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1525 else if (type.compare ("data")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1526 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1527 retval = property (new array_property (name, h, Matrix ())); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1528 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1529 if (args.length () > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1530 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1531 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1532 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1533 // FIXME -- additional argument could define constraints, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1534 // but is this really useful? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1535 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1536 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1537 else if (type.compare ("color")) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1538 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1539 color_values cv (0, 0, 0); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1540 radio_values rv; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1541 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1542 if (args.length () > 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1543 rv = radio_values (args(1).string_value ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1544 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1545 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1546 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1547 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
|
1548 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1549 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1550 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1551 if (args.length () > 0 && ! args(0).is_empty ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1552 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1553 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1554 retval.set (rv.default_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1555 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1556 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1557 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1558 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1559 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1560 caseless_str go_name, go_rest; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1561 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1562 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
|
1563 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1564 graphics_object go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1565 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1566 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
|
1567 dprop_obj_map.find (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1568 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1569 if (it == dprop_obj_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1570 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1571 base_graphics_object *bgo = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1572 make_graphics_object_from_type (go_name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1573 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1574 if (bgo) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1575 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1576 go = graphics_object (bgo); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1577 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1578 dprop_obj_map[go_name] = go; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1579 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1580 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1581 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1582 go = it->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1583 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1584 if (go.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1585 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1586 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
|
1587 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1588 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1589 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1590 retval = prop.clone (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1591 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1592 retval.set_parent (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1593 retval.set_name (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1594 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1595 if (args.length () > 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1596 retval.set (args(0)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1597 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1598 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1599 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1600 error ("addproperty: invalid object type (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1601 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1602 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1603 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1604 error ("addproperty: unsupported type for dynamic property (= %s)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1605 type.c_str ()); |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1606 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1607 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1608 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1609 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
1610 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1611 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1612 finalize_r (const graphics_handle& h) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1613 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1614 graphics_object go = gh_manager::get_object (h); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1615 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1616 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1617 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1618 Matrix children = go.get_properties ().get_all_children (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1619 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1620 for (int k = 0; k < children.numel (); k++) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1621 finalize_r (children(k)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1622 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1623 go.finalize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1624 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1625 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1626 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1627 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1628 initialize_r (const graphics_handle& h) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1629 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1630 graphics_object go = gh_manager::get_object (h); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1631 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1632 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1633 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1634 Matrix children = go.get_properties ().get_all_children (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1635 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1636 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1637 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1638 for (int k = 0; k < children.numel (); k++) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1639 initialize_r (children(k)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1640 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1641 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1642 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1643 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1644 figure::properties::set_toolkit (const graphics_toolkit& b) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1645 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1646 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1647 finalize_r (get___myhandle__ ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1648 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1649 toolkit = b; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1650 __graphics_toolkit__ = b.get_name (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1651 __plot_stream__ = Matrix (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1652 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1653 if (toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1654 initialize_r (get___myhandle__ ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1655 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1656 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1657 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1658 |
7363 | 1659 // --------------------------------------------------------------------- |
6681 | 1660 |
6705 | 1661 void |
7189 | 1662 property_list::set (const caseless_str& name, const octave_value& val) |
6681 | 1663 { |
6705 | 1664 size_t offset = 0; |
6681 | 1665 |
6705 | 1666 size_t len = name.length (); |
6681 | 1667 |
6705 | 1668 if (len > 4) |
1669 { | |
7189 | 1670 caseless_str pfx = name.substr (0, 4); |
6681 | 1671 |
6705 | 1672 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1673 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1674 offset = 4; |
6705 | 1675 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1676 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1677 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1678 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1679 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1680 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1681 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1682 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1683 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1684 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1685 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1686 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1687 else if (len > 7) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1688 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1689 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1690 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1691 if (pfx.compare ("surface") || pfx.compare ("hggroup") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1692 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1693 offset = 7; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1694 else if (len > 9) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1695 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1696 pfx = name.substr (0, 9); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1697 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1698 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1699 || pfx.compare ("uitoolbar")) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1700 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1701 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1702 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1703 pfx = name.substr (0, 10); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1704 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1705 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1706 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1707 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1708 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1709 pfx = name.substr (0, 12); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1710 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1711 if (pfx.compare ("uitoogletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1712 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1713 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1714 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1715 pfx = name.substr (0, 13); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1716 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1717 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1718 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1719 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1720 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1721 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1722 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1723 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1724 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1725 } |
6681 | 1726 |
6705 | 1727 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1728 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1729 // 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
|
1730 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1731 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1732 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1733 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
|
1734 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
|
1735 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1736 bool has_property = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1737 if (pfx == "axes") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1738 has_property = axes::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1739 else if (pfx == "line") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1740 has_property = line::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1741 else if (pfx == "text") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1742 has_property = text::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1743 else if (pfx == "image") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1744 has_property = image::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1745 else if (pfx == "patch") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1746 has_property = patch::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1747 else if (pfx == "figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1748 has_property = figure::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1749 else if (pfx == "surface") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1750 has_property = surface::properties::has_core_property (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1751 else if (pfx == "hggroup") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1752 has_property = hggroup::properties::has_core_property (pname); |
11283 | 1753 else if (pfx == "uimenu") |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1754 has_property = uimenu::properties::has_core_property (pname); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1755 else if (pfx == "uicontrol") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1756 has_property = uicontrol::properties::has_core_property (pname); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1757 else if (pfx == "uipanel") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1758 has_property = uipanel::properties::has_core_property (pname); |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1759 else if (pfx == "uicontextmenu") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1760 has_property = uicontextmenu::properties::has_core_property (pname); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1761 else if (pfx == "uitoolbar") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1762 has_property = uitoolbar::properties::has_core_property (pname); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1763 else if (pfx == "uipushtool") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1764 has_property = uipushtool::properties::has_core_property (pname); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1765 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1766 if (has_property) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1767 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1768 bool remove = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1769 if (val.is_string ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1770 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1771 caseless_str tval = val.string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1772 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1773 remove = tval.compare ("remove"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1774 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1775 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1776 pval_map_type& pval_map = plist_map[pfx]; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1777 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1778 if (remove) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1779 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1780 pval_map_iterator p = pval_map.find (pname); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1781 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1782 if (p != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1783 pval_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1784 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1785 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1786 pval_map[pname] = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1787 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1788 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1789 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
|
1790 } |
6705 | 1791 } |
6406 | 1792 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
1793 if (! error_state && offset == 0) |
6705 | 1794 error ("invalid default property specification"); |
1795 } | |
6406 | 1796 |
6705 | 1797 octave_value |
7189 | 1798 property_list::lookup (const caseless_str& name) const |
6705 | 1799 { |
1800 octave_value retval; | |
6406 | 1801 |
6705 | 1802 size_t offset = 0; |
6406 | 1803 |
6705 | 1804 size_t len = name.length (); |
6406 | 1805 |
6705 | 1806 if (len > 4) |
1807 { | |
7189 | 1808 caseless_str pfx = name.substr (0, 4); |
6406 | 1809 |
6705 | 1810 if (pfx.compare ("axes") || pfx.compare ("line") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1811 || pfx.compare ("text")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1812 offset = 4; |
6705 | 1813 else if (len > 5) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1814 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1815 pfx = name.substr (0, 5); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1816 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1817 if (pfx.compare ("image") || pfx.compare ("patch")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1818 offset = 5; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1819 else if (len > 6) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1820 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1821 pfx = name.substr (0, 6); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1822 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
1823 if (pfx.compare ("figure") || pfx.compare ("uimenu")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1824 offset = 6; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1825 else if (len > 7) |
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 pfx = name.substr (0, 7); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1828 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1829 if (pfx.compare ("surface") || pfx.compare ("hggroup") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1830 || pfx.compare ("uipanel")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1831 offset = 7; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1832 else if (len > 9) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1833 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1834 pfx = name.substr (0, 9); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1835 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1836 if (pfx.compare ("uicontrol") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1837 || pfx.compare ("uitoolbar")) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1838 offset = 9; |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1839 else if (len > 10) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1840 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1841 pfx = name.substr (0, 10); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1842 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1843 if (pfx.compare ("uipushtool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1844 offset = 10; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1845 else if (len > 12) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1846 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1847 pfx = name.substr (0, 12); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1848 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1849 if (pfx.compare ("uitoggletool")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1850 offset = 12; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1851 else if (len > 13) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1852 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1853 pfx = name.substr (0, 13); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1854 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1855 if (pfx.compare ("uicontextmenu")) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1856 offset = 13; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1857 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1858 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
1859 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
1860 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1861 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1862 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1863 } |
6406 | 1864 |
6705 | 1865 if (offset > 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1866 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1867 std::string pname = name.substr (offset); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1868 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1869 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
|
1870 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
|
1871 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1872 plist_map_const_iterator p = find (pfx); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1873 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1874 if (p != end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1875 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1876 const pval_map_type& pval_map = p->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1877 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1878 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
|
1879 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1880 if (q != pval_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1881 retval = q->second; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1882 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1883 } |
6705 | 1884 } |
6406 | 1885 |
6705 | 1886 return retval; |
1887 } | |
6406 | 1888 |
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
|
1889 octave_scalar_map |
6705 | 1890 property_list::as_struct (const std::string& prefix_arg) const |
1891 { | |
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
|
1892 octave_scalar_map m; |
6406 | 1893 |
6705 | 1894 for (plist_map_const_iterator p = begin (); p != end (); p++) |
1895 { | |
1896 std::string prefix = prefix_arg + p->first; | |
6406 | 1897 |
6705 | 1898 const pval_map_type pval_map = p->second; |
6406 | 1899 |
6705 | 1900 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
|
1901 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1902 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1903 m.assign (prefix + q->first, q->second); |
6705 | 1904 } |
6406 | 1905 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
1906 return m; |
6705 | 1907 } |
6432 | 1908 |
6874 | 1909 graphics_handle::graphics_handle (const octave_value& a) |
1910 : val (octave_NaN) | |
1911 { | |
1912 if (a.is_empty ()) | |
1913 /* do nothing */; | |
1914 else | |
1915 { | |
1916 double tval = a.double_value (); | |
1917 | |
1918 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1919 val = tval; |
6874 | 1920 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1921 error ("invalid graphics handle"); |
6874 | 1922 } |
1923 } | |
1924 | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1925 // 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
|
1926 |
6705 | 1927 void |
1928 graphics_object::set (const octave_value_list& args) | |
1929 { | |
1930 int nargin = args.length (); | |
6406 | 1931 |
6705 | 1932 if (nargin == 0) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
1933 error ("graphics_object::set: Nothing to set"); |
6705 | 1934 else if (nargin % 2 == 0) |
1935 { | |
1936 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
|
1937 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1938 caseless_str name = args(i).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1939 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1940 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1941 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1942 octave_value val = args(i+1); |
6406 | 1943 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1944 set_value_or_default (name, val); |
6406 | 1945 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1946 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1947 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1948 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1949 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
1950 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
|
1951 } |
6705 | 1952 } |
1953 else | |
1954 error ("set: invalid number of arguments"); | |
1955 } | |
6406 | 1956 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1957 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1958 %!# 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
|
1959 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1960 %! set(gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1961 %! 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
|
1962 %! 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
|
1963 %! 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
|
1964 %! 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
|
1965 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1966 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1967 // 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
|
1968 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1969 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
|
1970 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
|
1971 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1972 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
|
1973 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1974 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
|
1975 names.numel (), values.columns ()); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1976 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1977 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1978 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
|
1979 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1980 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
|
1981 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1982 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
|
1983 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
|
1984 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1985 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
|
1986 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1987 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1988 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1989 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1990 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1991 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1992 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1993 %!# 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
|
1994 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1995 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
1996 %! 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
|
1997 %! 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
|
1998 %! 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
|
1999 %! 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
|
2000 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2001 %!# 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
|
2002 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2003 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2004 %! 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
|
2005 %! 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
|
2006 %! 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
|
2007 %! 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
|
2008 %! 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
|
2009 %! 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
|
2010 %! 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
|
2011 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2012 %!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
|
2013 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2014 %! 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
|
2015 %! 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
|
2016 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2017 %!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
|
2018 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2019 %! 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
|
2020 %! 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
|
2021 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2022 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2023 // 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
|
2024 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
|
2025 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
|
2026 { |
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
|
2027 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
|
2028 p != m.end (); p++) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2029 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2030 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
|
2031 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2032 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
|
2033 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2034 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
|
2035 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2036 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2037 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2038 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2039 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2040 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2041 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2042 %!# 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
|
2043 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2044 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2045 %! 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
|
2046 %! 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
|
2047 %! 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
|
2048 %! 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
|
2049 %! 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
|
2050 %! 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
|
2051 %! 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
|
2052 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2053 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2054 // 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
|
2055 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2056 void |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2057 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
|
2058 const octave_value& val) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2059 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2060 if (val.is_string ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2061 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2062 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
|
2063 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2064 octave_value default_val; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2065 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2066 if (tval.compare ("default")) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2067 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2068 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
|
2069 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2070 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2071 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2072 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2073 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
|
2074 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2075 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
|
2076 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2077 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
|
2078 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2079 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2080 return; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2081 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2082 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
|
2083 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2084 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2085 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2086 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2087 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2088 rep->set (name, val); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2089 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2090 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2091 /* |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2092 %!# 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
|
2093 %!test |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2094 %! set (gcf, "visible", "off"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2095 %! 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
|
2096 %! set (0, "defaultlinelinewidth", 20); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2097 %! set (h, "linewidth", "default"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2098 %! 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
|
2099 %! set (h, "linewidth", "factory"); |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2100 %! 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
|
2101 */ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
2102 |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2103 static double |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2104 make_handle_fraction (void) |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2105 { |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2106 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
|
2107 |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2108 return (rand () + 1.0) / maxrand; |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2109 } |
6406 | 2110 |
6705 | 2111 graphics_handle |
2112 gh_manager::get_handle (const std::string& go_name) | |
2113 { | |
2114 graphics_handle retval; | |
6406 | 2115 |
6705 | 2116 if (go_name == "figure") |
2117 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2118 // 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
|
2119 // figure number. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2120 |
6705 | 2121 // We always want the lowest unused figure number. |
6406 | 2122 |
6705 | 2123 retval = 1; |
6425 | 2124 |
6705 | 2125 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
|
2126 retval++; |
6705 | 2127 } |
2128 else | |
2129 { | |
8234
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2130 // 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
|
2131 // 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
|
2132 // 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
|
2133 // time. |
8c4e79668a5e
generate new fractional parts for recycled graphics handles
John W. Eaton <jwe@octave.org>
parents:
8233
diff
changeset
|
2134 |
6705 | 2135 free_list_iterator p = handle_free_list.begin (); |
6406 | 2136 |
6705 | 2137 if (p != handle_free_list.end ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2138 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2139 retval = *p; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2140 handle_free_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2141 } |
6705 | 2142 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2143 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2144 retval = graphics_handle (next_handle); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2145 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
2146 next_handle = std::ceil (next_handle) - 1.0 - make_handle_fraction (); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2147 } |
6705 | 2148 } |
6406 | 2149 |
6705 | 2150 return retval; |
2151 } | |
6406 | 2152 |
6705 | 2153 void |
2154 gh_manager::do_free (const graphics_handle& h) | |
2155 { | |
7056 | 2156 if (h.ok ()) |
6705 | 2157 { |
6874 | 2158 if (h.value () != 0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2159 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2160 iterator p = handle_map.find (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2161 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2162 if (p != handle_map.end ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2163 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2164 base_properties& bp = p->second.get_properties (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2165 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2166 bp.set_beingdeleted (true); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2167 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2168 bp.delete_children (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2169 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2170 octave_value val = bp.get_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2171 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2172 bp.execute_deletefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2173 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2174 // Notify graphics toolkit. |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2175 p->second.finalize (); |
8208 | 2176 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2177 // Note: this will be valid only for first explicitly |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2178 // deleted object. All its children will then have an |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2179 // unknown graphics toolkit. |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2180 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2181 // Graphics handles for non-figure objects are negative |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2182 // integers plus some random fractional part. To avoid |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2183 // 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
|
2184 // 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
|
2185 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2186 handle_map.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2187 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2188 if (h.value () < 0) |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
2189 handle_free_list.insert (std::ceil (h.value ()) - make_handle_fraction ()); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2190 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2191 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2192 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
|
2193 } |
6705 | 2194 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2195 error ("graphics_handle::free: can't delete root figure"); |
6705 | 2196 } |
2197 } | |
6406 | 2198 |
2199 gh_manager *gh_manager::instance = 0; | |
2200 | |
2201 static void | |
7189 | 2202 xset (const graphics_handle& h, const caseless_str& name, |
6406 | 2203 const octave_value& val) |
2204 { | |
2205 graphics_object obj = gh_manager::get_object (h); | |
2206 obj.set (name, val); | |
2207 } | |
2208 | |
2209 static void | |
2210 xset (const graphics_handle& h, const octave_value_list& args) | |
2211 { | |
2212 if (args.length () > 0) | |
2213 { | |
2214 graphics_object obj = gh_manager::get_object (h); | |
2215 obj.set (args); | |
2216 } | |
2217 } | |
2218 | |
2219 static octave_value | |
7189 | 2220 xget (const graphics_handle& h, const caseless_str& name) |
6406 | 2221 { |
2222 graphics_object obj = gh_manager::get_object (h); | |
2223 return obj.get (name); | |
2224 } | |
2225 | |
2226 static graphics_handle | |
2227 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
|
2228 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
|
2229 bool adopt = true) |
6406 | 2230 { |
2231 graphics_handle h = octave_NaN; | |
2232 | |
2233 double val = ov.double_value (); | |
2234 | |
2235 if (! error_state) | |
2236 { | |
2237 h = gh_manager::lookup (val); | |
2238 | |
7056 | 2239 if (h.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2240 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2241 graphics_object obj = gh_manager::get_object (h); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2242 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2243 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2244 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2245 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
|
2246 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2247 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2248 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2249 if (adopt) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2250 obj.set ("parent", new_parent.value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2251 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2252 obj.reparent (new_parent); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2253 } |
6406 | 2254 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2255 error ("%s: invalid graphics handle (= %g) for %s", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2256 who.c_str (), val, property.c_str ()); |
6406 | 2257 } |
2258 else | |
2259 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
|
2260 who.c_str (), property.c_str ()); |
6406 | 2261 |
2262 return h; | |
2263 } | |
2264 | |
2265 // This function is NOT equivalent to the scripting language function gcf. | |
2266 graphics_handle | |
2267 gcf (void) | |
2268 { | |
2269 octave_value val = xget (0, "currentfigure"); | |
2270 | |
2271 return val.is_empty () ? octave_NaN : val.double_value (); | |
2272 } | |
2273 | |
2274 // This function is NOT equivalent to the scripting language function gca. | |
2275 graphics_handle | |
2276 gca (void) | |
2277 { | |
2278 octave_value val = xget (gcf (), "currentaxes"); | |
2279 | |
2280 return val.is_empty () ? octave_NaN : val.double_value (); | |
2281 } | |
2282 | |
2283 static void | |
2284 adopt (const graphics_handle& p, const graphics_handle& h) | |
2285 { | |
2286 graphics_object parent_obj = gh_manager::get_object (p); | |
2287 parent_obj.adopt (h); | |
2288 } | |
2289 | |
2290 static bool | |
7056 | 2291 is_handle (const graphics_handle& h) |
2292 { | |
2293 return h.ok (); | |
2294 } | |
2295 | |
2296 static bool | |
6406 | 2297 is_handle (double val) |
2298 { | |
6874 | 2299 graphics_handle h = gh_manager::lookup (val); |
2300 | |
2301 return h.ok (); | |
6406 | 2302 } |
2303 | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2304 static octave_value |
6406 | 2305 is_handle (const octave_value& val) |
2306 { | |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2307 octave_value retval = false; |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2308 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2309 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
|
2310 retval = true; |
12587
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2311 else if (val.is_numeric_type () && val.is_real_type ()) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2312 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2313 const NDArray handles = val.array_value (); |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2314 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2315 if (! error_state) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2316 { |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2317 boolNDArray result (handles.dims ()); |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2318 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2319 for (octave_idx_type i = 0; i < handles.numel (); i++) |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2320 result.xelem (i) = is_handle (handles (i)); |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2321 |
c3d4542a4f06
graphics.cc: Allow ishandle() to accept vector of handles (bug 33025).
John Eaton <jwe@octave.org>
parents:
12549
diff
changeset
|
2322 retval = result; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2323 } |
8183
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2324 } |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2325 |
277218396978
Handle arrays of handles in the Fishandle function
David Bateman <dbateman@free.fr>
parents:
8102
diff
changeset
|
2326 return retval; |
6406 | 2327 } |
2328 | |
2329 static bool | |
2330 is_figure (double val) | |
2331 { | |
2332 graphics_object obj = gh_manager::get_object (val); | |
2333 | |
2334 return obj && obj.isa ("figure"); | |
2335 } | |
2336 | |
7370 | 2337 static void |
2338 xcreatefcn (const graphics_handle& h) | |
2339 { | |
2340 graphics_object obj = gh_manager::get_object (h); | |
2341 obj.get_properties ().execute_createfcn (); | |
2342 } | |
2343 | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2344 static void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2345 xinitialize (const graphics_handle& h) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2346 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2347 graphics_object go = gh_manager::get_object (h); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2348 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2349 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2350 go.initialize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2351 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2352 |
6406 | 2353 // --------------------------------------------------------------------- |
2354 | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2355 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2356 base_graphics_toolkit::update (const graphics_handle& h, int id) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2357 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2358 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2359 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2360 update (go, id); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2361 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2362 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2363 bool |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2364 base_graphics_toolkit::initialize (const graphics_handle& h) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2365 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2366 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2367 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2368 return initialize (go); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2369 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2370 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2371 void |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2372 base_graphics_toolkit::finalize (const graphics_handle& h) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2373 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2374 graphics_object go = gh_manager::get_object (h); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2375 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2376 finalize (go); |
8059
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 // --------------------------------------------------------------------- |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2379 |
6705 | 2380 void |
2381 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
|
2382 property_list& defaults) |
6406 | 2383 { |
6705 | 2384 std::string go_name = graphics_object_name (); |
6406 | 2385 |
6705 | 2386 property_list::plist_map_const_iterator p = defaults.find (go_name); |
6406 | 2387 |
6705 | 2388 if (p != defaults.end ()) |
2389 { | |
2390 const property_list::pval_map_type pval_map = p->second; | |
6406 | 2391 |
6705 | 2392 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
|
2393 q != pval_map.end (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2394 q++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2395 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2396 std::string pname = q->first; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2397 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2398 obj.set (pname, q->second); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2399 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2400 if (error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2401 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2402 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
|
2403 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2404 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2405 } |
6705 | 2406 } |
2407 } | |
6406 | 2408 |
7363 | 2409 octave_value |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2410 base_properties::get_dynamic (const caseless_str& name) const |
7363 | 2411 { |
2412 octave_value retval; | |
2413 | |
8090 | 2414 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
|
2415 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2416 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2417 retval = it->second.get (); |
7363 | 2418 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2419 error ("get: unknown property \"%s\"", name.c_str ()); |
7363 | 2420 |
2421 return retval; | |
2422 } | |
2423 | |
2424 octave_value | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2425 base_properties::get_dynamic (bool all) const |
7363 | 2426 { |
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
|
2427 octave_scalar_map m; |
7363 | 2428 |
8090 | 2429 for (std::map<caseless_str, property, cmp_caseless_str>::const_iterator it = all_props.begin (); |
7363 | 2430 it != all_props.end (); ++it) |
7379 | 2431 if (all || ! it->second.is_hidden ()) |
2432 m.assign (it->second.get_name (), it->second.get ()); | |
7363 | 2433 |
2434 return m; | |
2435 } | |
2436 | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2437 std::set<std::string> |
9972 | 2438 base_properties::dynamic_property_names (void) const |
2439 { | |
2440 return dynamic_properties; | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2441 } |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
2442 |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2443 bool |
9972 | 2444 base_properties::has_dynamic_property (const std::string& pname) |
2445 { | |
2446 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
|
2447 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2448 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
|
2449 } |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2450 |
7363 | 2451 void |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2452 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
|
2453 const octave_value& val) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2454 { |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2455 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
|
2456 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2457 if (it != all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2458 it->second.set (val); |
7363 | 2459 else |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2460 error ("set: unknown property \"%s\"", pname.c_str ()); |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2461 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2462 if (! error_state) |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2463 { |
9972 | 2464 dynamic_properties.insert (pname); |
9185
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2465 |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2466 mark_modified (); |
1e5c11890f85
check for invalid property names when setting defaults
John W. Eaton <jwe@octave.org>
parents:
9181
diff
changeset
|
2467 } |
7363 | 2468 } |
2469 | |
2470 property | |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2471 base_properties::get_property_dynamic (const caseless_str& name) |
7363 | 2472 { |
8090 | 2473 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
|
2474 |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2475 if (it == all_props.end ()) |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2476 { |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2477 error ("get_property: unknown property \"%s\"", name.c_str ()); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2478 return property (); |
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2479 } |
7363 | 2480 else |
8061
f819e8992367
Auto-generate base_properties
John W. Eaton <jwe@octave.org>
parents:
8059
diff
changeset
|
2481 return it->second; |
7363 | 2482 } |
2483 | |
6705 | 2484 void |
6836 | 2485 base_properties::set_parent (const octave_value& val) |
6705 | 2486 { |
2487 double tmp = val.double_value (); | |
6406 | 2488 |
6705 | 2489 graphics_handle new_parent = octave_NaN; |
6406 | 2490 |
6705 | 2491 if (! error_state) |
2492 { | |
2493 new_parent = gh_manager::lookup (tmp); | |
6406 | 2494 |
7056 | 2495 if (new_parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2496 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2497 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
|
2498 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2499 parent_obj.remove_child (__myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2500 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2501 parent = new_parent.as_octave_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2502 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2503 ::adopt (parent.handle_value (), __myhandle__); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2504 } |
6705 | 2505 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2506 error ("set: invalid graphics handle (= %g) for parent", tmp); |
6705 | 2507 } |
2508 else | |
2509 error ("set: expecting parent to be a graphics handle"); | |
2510 } | |
6432 | 2511 |
6705 | 2512 void |
6836 | 2513 base_properties::mark_modified (void) |
2514 { | |
7363 | 2515 __modified__ = "on"; |
2516 graphics_object parent_obj = gh_manager::get_object (get_parent ()); | |
7379 | 2517 if (parent_obj) |
2518 parent_obj.mark_modified (); | |
6836 | 2519 } |
2520 | |
2521 void | |
2522 base_properties::override_defaults (base_graphics_object& obj) | |
2523 { | |
7363 | 2524 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
|
2525 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2526 if (parent_obj) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
2527 parent_obj.override_defaults (obj); |
6836 | 2528 } |
2529 | |
2530 void | |
7214 | 2531 base_properties::update_axis_limits (const std::string& axis_type) const |
2532 { | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2533 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
|
2534 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2535 if (obj) |
7214 | 2536 obj.update_axis_limits (axis_type); |
2537 } | |
2538 | |
2539 void | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2540 base_properties::update_axis_limits (const std::string& axis_type, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2541 const graphics_handle& h) const |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2542 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2543 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2544 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2545 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2546 obj.update_axis_limits (axis_type, h); |
6836 | 2547 } |
2548 | |
13324
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2549 bool |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2550 base_properties::is_handle_visible (void) const |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2551 { |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2552 return (handlevisibility.is ("on") |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
2553 || (executing_callback && ! handlevisibility.is ("off"))); |
13324
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2554 } |
1e12601d2697
make handles with their handlevisibility property set to "callback" visible in callback functions
John W. Eaton <jwe@octave.org>
parents:
13323
diff
changeset
|
2555 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2556 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2557 base_properties::get_toolkit (void) const |
7419 | 2558 { |
2559 graphics_object go = gh_manager::get_object (get_parent ()); | |
2560 | |
2561 if (go) | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2562 return go.get_toolkit (); |
7419 | 2563 else |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2564 return graphics_toolkit (); |
7419 | 2565 } |
2566 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2567 void |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2568 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
|
2569 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2570 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
|
2571 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2572 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
|
2573 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2574 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
|
2575 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2576 if (go.valid_object ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2577 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
|
2578 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2579 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
2580 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2581 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2582 base_properties::update_autopos (const std::string& elem_type) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2583 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2584 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2585 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2586 if (parent_obj.valid_object ()) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2587 parent_obj.get_properties ().update_autopos (elem_type); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2588 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2589 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
2590 void |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2591 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
|
2592 listener_mode mode) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2593 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2594 property p = get_property (nm); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2595 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2596 if (! error_state && p.ok ()) |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2597 p.add_listener (v, mode); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2598 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
2599 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2600 void |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2601 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
|
2602 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
|
2603 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2604 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
|
2605 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2606 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
|
2607 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
|
2608 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2609 |
7363 | 2610 // --------------------------------------------------------------------- |
2611 | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2612 class gnuplot_toolkit : public base_graphics_toolkit |
7408 | 2613 { |
2614 public: | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2615 gnuplot_toolkit (void) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2616 : base_graphics_toolkit ("gnuplot") { } |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2617 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2618 ~gnuplot_toolkit (void) { } |
7408 | 2619 |
2620 bool is_valid (void) const { return true; } | |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2621 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2622 bool initialize (const graphics_object& go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2623 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2624 return go.isa ("figure"); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2625 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
2626 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2627 void finalize (const graphics_object& go) |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2628 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2629 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2630 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2631 const figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2632 dynamic_cast<const figure::properties&> (go.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2633 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2634 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2635 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2636 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2637 |
10973
a8235d26b57a
improve names of base_graphics_backend methods
John W. Eaton <jwe@octave.org>
parents:
10949
diff
changeset
|
2638 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
|
2639 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2640 if (go.isa ("figure")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2641 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2642 graphics_object obj (go); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2643 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2644 figure::properties& props = |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2645 dynamic_cast<figure::properties&> (obj.get_properties ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2646 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2647 switch (id) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2648 { |
11239
5fa7667f90e5
Add prefix ID_ to property ids to avoid name clash on windows
Kai Habel <kai.habel@gmx.de>
parents:
11175
diff
changeset
|
2649 case base_properties::ID_VISIBLE: |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2650 if (! props.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2651 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2652 send_quit (props.get___plot_stream__ ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2653 props.set___plot_stream__ (Matrix ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2654 props.set___enhanced__ (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2655 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2656 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2657 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2658 } |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2659 } |
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 void redraw_figure (const graphics_object& go) const |
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 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2664 args(0) = go.get_handle ().as_octave_value (); |
12221
a91037b36b4c
rename gnuplot_drawnow to __gnuplot_drawnow__
John W. Eaton <jwe@octave.org>
parents:
12215
diff
changeset
|
2665 feval ("__gnuplot_drawnow__", args); |
8059
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 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2668 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
|
2669 const std::string& file, bool mono, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2670 const std::string& debug_file) const |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2671 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2672 octave_value_list args; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2673 if (! debug_file.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2674 args(4) = debug_file; |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2675 args(3) = mono; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2676 args(2) = file; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2677 args(1) = term; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2678 args(0) = go.get_handle ().as_octave_value (); |
12221
a91037b36b4c
rename gnuplot_drawnow to __gnuplot_drawnow__
John W. Eaton <jwe@octave.org>
parents:
12215
diff
changeset
|
2679 feval ("__gnuplot_drawnow__", args); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2680 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2681 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2682 Matrix get_canvas_size (const graphics_handle&) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2683 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2684 Matrix sz (1, 2, 0.0); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2685 return sz; |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2686 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2687 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2688 double get_screen_resolution (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2689 { return 72.0; } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2690 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2691 Matrix get_screen_size (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2692 { return Matrix (1, 2, 0.0); } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2693 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2694 private: |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2695 void send_quit (const octave_value& pstream) const |
7408 | 2696 { |
9561
c60a9e1a0372
try to avoid gnuplot zombies
John W. Eaton <jwe@octave.org>
parents:
9455
diff
changeset
|
2697 if (! pstream.is_empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2698 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2699 octave_value_list args; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2700 Matrix fids = pstream.matrix_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2701 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2702 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2703 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2704 args(1) = "\nquit;\n"; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2705 args(0) = fids(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2706 feval ("fputs", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2707 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2708 args.resize (1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2709 feval ("fflush", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2710 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2711 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2712 if (fids.numel () > 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2713 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2714 args(0) = fids(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2715 feval ("pclose", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2716 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2717 if (fids.numel () > 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2718 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2719 args(0) = fids(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2720 feval ("waitpid", args); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2721 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2722 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2723 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2724 } |
7408 | 2725 } |
2726 }; | |
2727 | |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2728 graphics_toolkit |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2729 graphics_toolkit::default_toolkit (void) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2730 { |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2731 if (available_toolkits.size () == 0) |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2732 register_toolkit (new gnuplot_toolkit ()); |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2733 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2734 return available_toolkits["gnuplot"]; |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2735 } |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2736 |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
2737 std::map<std::string, graphics_toolkit> graphics_toolkit::available_toolkits; |
7408 | 2738 |
2739 // --------------------------------------------------------------------- | |
2740 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2741 void |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2742 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
|
2743 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2744 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
|
2745 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2746 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
|
2747 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2748 if (parent_obj) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2749 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
|
2750 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2751 else |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2752 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
|
2753 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2754 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2755 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2756 base_graphics_object::update_axis_limits (const std::string& axis_type, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2757 const graphics_handle& h) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2758 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2759 if (valid_object ()) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2760 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2761 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2762 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2763 if (parent_obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2764 parent_obj.update_axis_limits (axis_type, h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2765 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2766 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2767 error ("base_graphics_object::update_axis_limits: invalid graphics object"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2768 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2769 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
2770 void |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2771 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
|
2772 { |
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
|
2773 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
|
2774 |
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
|
2775 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
|
2776 { |
9585
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2777 // 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
|
2778 // 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
|
2779 // 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
|
2780 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2781 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2782 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2783 frame.protect_var (discard_error_messages); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
2784 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
|
2785 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2786 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
|
2787 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2788 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
|
2789 |
06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
John W. Eaton <jwe@octave.org>
parents:
9584
diff
changeset
|
2790 if (! error_state && p.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2791 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
|
2792 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2793 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
2794 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2795 std::string |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2796 base_graphics_object::values_as_string (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2797 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2798 std::string retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2799 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2800 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2801 { |
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
|
2802 octave_map m = get ().map_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2803 |
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
|
2804 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
|
2805 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2806 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2807 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2808 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2809 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2810 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2811 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2812 retval += "\n\t" + std::string (pa->first) + ": "; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2813 if (p.is_radio ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2814 retval += p.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2815 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2816 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2817 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2818 if (retval != "") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2819 retval += "\n"; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2820 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2821 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2822 error ("base_graphics_object::values_as_string: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2823 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2824 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2825 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2826 |
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
|
2827 octave_scalar_map |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2828 base_graphics_object::values_as_struct (void) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2829 { |
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
|
2830 octave_scalar_map retval; |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2831 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2832 if (valid_object ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2833 { |
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
|
2834 octave_scalar_map m = get ().scalar_map_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2835 |
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
|
2836 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
|
2837 pa != m.end (); pa++) |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2838 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2839 if (pa->first != "children") |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2840 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2841 property p = get_properties ().get_property (pa->first); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2842 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2843 if (p.ok () && ! p.is_hidden ()) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2844 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2845 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
|
2846 retval.assign (p.get_name (), p.values_as_cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2847 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
|
2848 retval.assign (p.get_name (), Cell ()); |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2849 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2850 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2851 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2852 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2853 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2854 error ("base_graphics_object::values_as_struct: invalid graphics object"); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2855 |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2856 return retval; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2857 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
2858 |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2859 graphics_object |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2860 graphics_object::get_ancestor (const std::string& obj_type) const |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2861 { |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2862 if (valid_object ()) |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2863 { |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2864 if (isa (obj_type)) |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2865 return *this; |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2866 else |
11492
d86389a6dc3f
graphics.cc: avoid GCC warning
John W. Eaton <jwe@octave.org>
parents:
11456
diff
changeset
|
2867 return gh_manager::get_object (get_parent ()).get_ancestor (obj_type); |
11250
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2868 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2869 else |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2870 return graphics_object (); |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2871 } |
830b940e7ff4
Turn xget_ancestor into regular API
Michael Goffioul <michael.goffioul@gmail.com>
parents:
11239
diff
changeset
|
2872 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2873 // --------------------------------------------------------------------- |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
2874 |
7363 | 2875 #include "graphics-props.cc" |
2876 | |
2877 // --------------------------------------------------------------------- | |
2878 | |
6836 | 2879 void |
7363 | 2880 root_figure::properties::set_currentfigure (const octave_value& v) |
6874 | 2881 { |
7378 | 2882 graphics_handle val (v); |
7363 | 2883 |
6874 | 2884 if (error_state) |
2885 return; | |
2886 | |
7059 | 2887 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 2888 { |
2889 currentfigure = val; | |
2890 | |
7363 | 2891 gh_manager::push_figure (val); |
6874 | 2892 } |
2893 else | |
2894 gripe_set_invalid ("currentfigure"); | |
2895 } | |
2896 | |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2897 void |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2898 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
|
2899 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2900 graphics_handle val (v); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2901 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2902 if (error_state) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2903 return; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2904 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2905 if (xisnan (val.value ())) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2906 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2907 if (! cbo_stack.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2908 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2909 val = cbo_stack.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2910 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2911 cbo_stack.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2912 } |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2913 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2914 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2915 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2916 else if (is_handle (val)) |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2917 { |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2918 if (get_callbackobject ().ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
2919 cbo_stack.push_front (get_callbackobject ()); |
7822
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2920 |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2921 callbackobject = val; |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2922 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2923 else |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2924 gripe_set_invalid ("callbackobject"); |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2925 } |
edbaa13397ee
Implement callbackobject property in root object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7820
diff
changeset
|
2926 |
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
|
2927 // 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
|
2928 // 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
|
2929 // aren't set yet. |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2930 void |
8560
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2931 root_figure::properties::update_units (void) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2932 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2933 caseless_str xunits = get_units (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2934 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2935 Matrix ss = default_screensize (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2936 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2937 double dpi = get_screenpixelsperinch (); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2938 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2939 if (xunits.compare ("inches")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2940 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2941 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2942 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2943 ss(2) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2944 ss(3) /= dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2945 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2946 else if (xunits.compare ("centimeters")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2947 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2948 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2949 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2950 ss(2) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2951 ss(3) *= 2.54 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2952 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2953 else if (xunits.compare ("normalized")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2954 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2955 ss = Matrix (1, 4, 1.0); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2956 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2957 else if (xunits.compare ("points")) |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2958 { |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2959 ss(0) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2960 ss(1) = 0; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2961 ss(2) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2962 ss(3) *= 72 / dpi; |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2963 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2964 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2965 set_screensize (ss); |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2966 } |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2967 |
5cc594679cdc
get display characteristics from system
John W. Eaton <jwe@octave.org>
parents:
8557
diff
changeset
|
2968 void |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2969 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
|
2970 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2971 gh_manager::pop_figure (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2972 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2973 graphics_handle cf = gh_manager::current_figure (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2974 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2975 xset (0, "currentfigure", cf.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2976 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2977 base_properties::remove_child (gh); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2978 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
2979 |
6406 | 2980 property_list |
2981 root_figure::factory_properties = root_figure::init_factory_properties (); | |
2982 | |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2983 static void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
2984 reset_default_properties (property_list& default_properties) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2985 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2986 property_list new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2987 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2988 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
|
2989 p != default_properties.end (); p++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2990 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2991 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
|
2992 std::string prefix = p->first; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
2993 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2994 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
|
2995 q != pval_map.end (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2996 q++) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2997 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2998 std::string s = q->first; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
2999 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3000 if (prefix == "axes" && (s == "position" || s == "units")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3001 new_defaults.set (prefix + s, q->second); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3002 else if (prefix == "figure" && (s == "position" || s == "units" |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3003 || s == "windowstyle" |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3004 || s == "paperunits")) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3005 new_defaults.set (prefix + s, q->second); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3006 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3007 } |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3008 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3009 default_properties = new_defaults; |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3010 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3011 |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3012 void |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3013 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
|
3014 { |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3015 ::reset_default_properties (default_properties); |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3016 } |
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3017 |
6406 | 3018 // --------------------------------------------------------------------- |
3019 | |
7363 | 3020 void |
3021 figure::properties::set_currentaxes (const octave_value& v) | |
3022 { | |
7378 | 3023 graphics_handle val (v); |
6705 | 3024 |
6874 | 3025 if (error_state) |
3026 return; | |
3027 | |
7070 | 3028 if (xisnan (val.value ()) || is_handle (val)) |
6874 | 3029 currentaxes = val; |
3030 else | |
3031 gripe_set_invalid ("currentaxes"); | |
3032 } | |
3033 | |
3034 void | |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3035 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
|
3036 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3037 base_properties::remove_child (gh); |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3038 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3039 if (gh == currentaxes.handle_value ()) |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3040 { |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3041 graphics_handle new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3042 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3043 Matrix kids = get_children (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3044 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3045 for (octave_idx_type i = 0; i < kids.numel (); i++) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3046 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
3047 graphics_handle kid = kids(i); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3048 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3049 graphics_object go = gh_manager::get_object (kid); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3050 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3051 if (go.isa ("axes")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3052 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3053 new_currentaxes = kid; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3054 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3055 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3056 } |
8266
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3057 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3058 currentaxes = new_currentaxes; |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3059 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3060 } |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3061 |
81b124f463f9
properly update currentaxes when axes are deleted
John W. Eaton <jwe@octave.org>
parents:
8249
diff
changeset
|
3062 void |
6874 | 3063 figure::properties::set_visible (const octave_value& val) |
3064 { | |
3065 std::string s = val.string_value (); | |
3066 | |
3067 if (! error_state) | |
3068 { | |
3069 if (s == "on") | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3070 xset (0, "currentfigure", __myhandle__.value ()); |
6874 | 3071 |
3072 visible = val; | |
3073 } | |
3074 } | |
3075 | |
7445 | 3076 Matrix |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3077 figure::properties::get_boundingbox (bool internal, const Matrix&) const |
7445 | 3078 { |
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
|
3079 Matrix screen_size = screen_size_pixels (); |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3080 Matrix pos = (internal ? |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3081 get_position ().matrix_value () : |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3082 get_outerposition ().matrix_value ()); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3083 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3084 pos = convert_position (pos, get_units (), "pixels", screen_size); |
7445 | 3085 |
3086 pos(0)--; | |
3087 pos(1)--; | |
7447 | 3088 pos(1) = screen_size(1) - pos(1) - pos(3); |
7445 | 3089 |
3090 return pos; | |
3091 } | |
3092 | |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3093 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3094 figure::properties::set_boundingbox (const Matrix& bb, bool internal, |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3095 bool do_notify_toolkit) |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3096 { |
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
|
3097 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
|
3098 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
|
3099 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3100 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
|
3101 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
|
3102 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
|
3103 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
|
3104 |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3105 if (internal) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3106 set_position (pos, do_notify_toolkit); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3107 else |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3108 set_outerposition (pos, do_notify_toolkit); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3109 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3110 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3111 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3112 figure::properties::map_from_boundingbox (double x, double y) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3113 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3114 Matrix bb = get_boundingbox (true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3115 Matrix pos (1, 2, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3116 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3117 pos(0) = x; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3118 pos(1) = y; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3119 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3120 pos(1) = bb(3) - pos(1); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3121 pos(0)++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3122 pos = convert_position (pos, "pixels", get_units (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3123 bb.extract_n (0, 2, 1, 2)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3124 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3125 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3126 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3127 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3128 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3129 figure::properties::map_to_boundingbox (double x, double y) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3130 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3131 Matrix bb = get_boundingbox (true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3132 Matrix pos (1, 2, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3133 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3134 pos(0) = x; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3135 pos(1) = y; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3136 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3137 pos = convert_position (pos, get_units (), "pixels", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3138 bb.extract_n (0, 2, 1, 2)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3139 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3140 pos(1) = bb(3) - pos(1); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3141 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3142 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3143 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
3144 |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3145 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3146 figure::properties::set_position (const octave_value& v, |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3147 bool do_notify_toolkit) |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3148 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3149 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
|
3150 { |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3151 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
|
3152 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3153 old_bb = get_boundingbox (); |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3154 position.set (v, true, do_notify_toolkit); |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3155 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
|
3156 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3157 if (old_bb != new_bb) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3158 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3159 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
|
3160 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3161 execute_resizefcn (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3162 update_boundingbox (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3163 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3164 } |
7828
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3165 |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3166 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
|
3167 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3168 } |
4739b6a1925c
Implement resize handler mechanism (call resizefcn on figure resize and notify children).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7827
diff
changeset
|
3169 |
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
|
3170 void |
13713
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3171 figure::properties::set_outerposition (const octave_value& v, |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3172 bool do_notify_toolkit) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3173 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3174 if (! error_state) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3175 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3176 if (outerposition.set (v, true, do_notify_toolkit)) |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3177 { |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3178 mark_modified (); |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3179 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3180 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3181 } |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3182 |
d99aa455296e
Add outerposition property to figure objects.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13703
diff
changeset
|
3183 void |
10991
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3184 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
|
3185 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3186 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
|
3187 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3188 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
|
3189 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
|
3190 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
|
3191 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3192 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
|
3193 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
|
3194 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
|
3195 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3196 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
|
3197 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
|
3198 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3199 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
|
3200 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
|
3201 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3202 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3203 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3204 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3205 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3206 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3207 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
|
3208 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
|
3209 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3210 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
|
3211 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3212 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
|
3213 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
|
3214 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
|
3215 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3216 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
|
3217 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
|
3218 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
|
3219 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3220 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
|
3221 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3222 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
|
3223 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
|
3224 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3225 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3226 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3227 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3228 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3229 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3230 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
|
3231 papersize_from_type (const caseless_str punits, const caseless_str typ) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3232 { |
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
|
3233 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
|
3234 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3235 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
|
3236 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3237 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
|
3238 double mm2units; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3239 |
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
|
3240 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
|
3241 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3242 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
|
3243 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
|
3244 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3245 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
|
3246 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3247 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
|
3248 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
|
3249 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3250 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
|
3251 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3252 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
|
3253 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
|
3254 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3255 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3256 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
|
3257 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3258 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
|
3259 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
|
3260 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3261 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
|
3262 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3263 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
|
3264 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
|
3265 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3266 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
|
3267 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3268 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
|
3269 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
|
3270 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3271 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
|
3272 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3273 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
|
3274 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
|
3275 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3276 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
|
3277 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3278 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
|
3279 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
|
3280 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3281 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
|
3282 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3283 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
|
3284 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
|
3285 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3286 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
|
3287 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3288 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
|
3289 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
|
3290 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3291 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
|
3292 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3293 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
|
3294 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
|
3295 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3296 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
|
3297 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3298 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
|
3299 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
|
3300 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3301 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
|
3302 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3303 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
|
3304 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
|
3305 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3306 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
|
3307 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3308 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
|
3309 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
|
3310 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3311 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
|
3312 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3313 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
|
3314 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
|
3315 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3316 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
|
3317 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3318 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
|
3319 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
|
3320 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3321 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
|
3322 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3323 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
|
3324 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
|
3325 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3326 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
|
3327 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3328 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
|
3329 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
|
3330 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3331 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
|
3332 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3333 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
|
3334 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
|
3335 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3336 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
|
3337 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3338 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
|
3339 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
|
3340 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3341 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
|
3342 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3343 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
|
3344 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
|
3345 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3346 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
|
3347 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3348 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
|
3349 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
|
3350 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3351 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
|
3352 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3353 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
|
3354 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
|
3355 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3356 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
|
3357 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3358 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
|
3359 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
|
3360 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3361 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
|
3362 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3363 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
|
3364 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
|
3365 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3366 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
|
3367 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3368 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
|
3369 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
|
3370 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3371 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
|
3372 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3373 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
|
3374 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
|
3375 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3376 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
|
3377 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3378 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
|
3379 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
|
3380 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3381 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3382 |
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
|
3383 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
|
3384 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3385 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3386 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
|
3387 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
|
3388 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3389 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
|
3390 Matrix sz = get_papersize ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3391 |
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
|
3392 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
|
3393 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
|
3394 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
|
3395 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
|
3396 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3397 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
|
3398 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
|
3399 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3400 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
|
3401 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3402 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
|
3403 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3404 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
|
3405 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
|
3406 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3407 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
|
3408 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3409 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
|
3410 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
|
3411 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3412 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3413 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
|
3414 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3415 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
|
3416 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
|
3417 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3418 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
|
3419 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3420 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
|
3421 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
|
3422 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3423 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3424 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
|
3425 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
|
3426 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3427 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
|
3428 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
|
3429 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
|
3430 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
|
3431 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3432 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
|
3433 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
|
3434 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3435 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3436 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
|
3437 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
|
3438 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3439 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
|
3440 |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3441 if (! typ.compare ("<custom>")) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3442 // Call papersize.set rather than set_papersize to avoid loops between |
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
|
3443 // 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
|
3444 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
|
3445 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3446 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3447 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
|
3448 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
|
3449 { |
10994
9e1270a84a10
graphics.cc: Replace pagetype property value custom with <custom>.
Ben Abbott <bpabbott@mac.com>
parents:
10991
diff
changeset
|
3450 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
|
3451 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3452 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3453 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
|
3454 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
|
3455 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3456 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
|
3457 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3458 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
|
3459 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
|
3460 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3461 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
|
3462 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
|
3463 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3464 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3465 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3466 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3467 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
|
3468 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
|
3469 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3470 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
|
3471 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
|
3472 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
3473 |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3474 std::string |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3475 figure::properties::get_title (void) const |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3476 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3477 if (is_numbertitle ()) |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3478 { |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3479 std::ostringstream os; |
8062
e04a4beeb283
graphics.cc (figure::properties::get_title): avoid gcc warning
John W. Eaton <jwe@octave.org>
parents:
8061
diff
changeset
|
3480 std::string nm = get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3481 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3482 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
|
3483 if (! nm.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3484 os << ": " << get_name (); |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3485 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3486 return os.str (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3487 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3488 else |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3489 return get_name (); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3490 } |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
3491 |
6836 | 3492 octave_value |
7189 | 3493 figure::get_default (const caseless_str& name) const |
6836 | 3494 { |
3495 octave_value retval = default_properties.lookup (name); | |
3496 | |
3497 if (retval.is_undefined ()) | |
3498 { | |
3499 graphics_handle parent = get_parent (); | |
3500 graphics_object parent_obj = gh_manager::get_object (parent); | |
3501 | |
3502 retval = parent_obj.get_default (name); | |
3503 } | |
3504 | |
3505 return retval; | |
3506 } | |
3507 | |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3508 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3509 figure::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3510 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
3511 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3512 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
3513 |
6406 | 3514 // --------------------------------------------------------------------- |
3515 | |
8249 | 3516 void |
3517 axes::properties::init (void) | |
3518 { | |
3519 position.add_constraint (dim_vector (1, 4)); | |
3520 position.add_constraint (dim_vector (0, 0)); | |
3521 outerposition.add_constraint (dim_vector (1, 4)); | |
3522 colororder.add_constraint (dim_vector (-1, 3)); | |
3523 dataaspectratio.add_constraint (dim_vector (1, 3)); | |
3524 plotboxaspectratio.add_constraint (dim_vector (1, 3)); | |
3525 xlim.add_constraint (2); | |
3526 ylim.add_constraint (2); | |
3527 zlim.add_constraint (2); | |
3528 clim.add_constraint (2); | |
3529 alim.add_constraint (2); | |
3530 xtick.add_constraint (dim_vector (1, -1)); | |
3531 ytick.add_constraint (dim_vector (1, -1)); | |
3532 ztick.add_constraint (dim_vector (1, -1)); | |
3533 Matrix vw (1, 2, 0); | |
3534 vw(1) = 90; | |
3535 view = vw; | |
3536 view.add_constraint (dim_vector (1, 2)); | |
3537 cameraposition.add_constraint (dim_vector (1, 3)); | |
3538 Matrix upv (1, 3, 0.0); | |
3539 upv(2) = 1.0; | |
3540 cameraupvector = upv; | |
3541 cameraupvector.add_constraint (dim_vector (1, 3)); | |
3542 currentpoint.add_constraint (dim_vector (2, 3)); | |
3543 ticklength.add_constraint (dim_vector (1, 2)); | |
3544 tightinset.add_constraint (dim_vector (1, 4)); | |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3545 looseinset.add_constraint (dim_vector (1, 4)); |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
3546 update_font (); |
8249 | 3547 |
3548 x_zlim.resize (1, 2); | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3549 |
8249 | 3550 sx = "linear"; |
3551 sy = "linear"; | |
3552 sz = "linear"; | |
3553 | |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3554 calc_ticklabels (xtick, xticklabel, xscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3555 calc_ticklabels (ytick, yticklabel, yscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3556 calc_ticklabels (ztick, zticklabel, zscale.is ("log")); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3557 |
8249 | 3558 xset (xlabel.handle_value (), "handlevisibility", "off"); |
3559 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
3560 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
3561 xset (title.handle_value (), "handlevisibility", "off"); | |
3562 | |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3563 xset (xlabel.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3564 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3565 xset (ylabel.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3566 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3567 xset (zlabel.handle_value (), "horizontalalignment", "right"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3568 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3569 xset (title.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3570 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3571 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3572 xset (xlabel.handle_value (), "verticalalignment", "cap"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3573 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3574 xset (ylabel.handle_value (), "verticalalignment", "bottom"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3575 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3576 xset (title.handle_value (), "verticalalignment", "bottom"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3577 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3578 |
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3579 xset (ylabel.handle_value (), "rotation", 90.0); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3580 xset (ylabel.handle_value (), "rotationmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3581 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3582 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3583 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3584 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3585 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3586 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
3587 xset (title.handle_value (), "clipping", "off"); |
8557
ab82e19002c4
better compatibility for axis label properties
John W. Eaton <jwe@octave.org>
parents:
8503
diff
changeset
|
3588 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3589 xset (xlabel.handle_value (), "autopos_tag", "xlabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3590 xset (ylabel.handle_value (), "autopos_tag", "ylabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3591 xset (zlabel.handle_value (), "autopos_tag", "zlabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3592 xset (title.handle_value (), "autopos_tag", "title"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3593 |
8249 | 3594 adopt (xlabel.handle_value ()); |
3595 adopt (ylabel.handle_value ()); | |
3596 adopt (zlabel.handle_value ()); | |
3597 adopt (title.handle_value ()); | |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3598 |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3599 Matrix tlooseinset = default_axes_position (); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3600 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3601 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3602 looseinset = tlooseinset; |
8249 | 3603 } |
3604 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3605 Matrix |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3606 axes::properties::calc_tightbox (const Matrix& init_pos) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3607 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3608 Matrix pos = init_pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3609 graphics_object obj = gh_manager::get_object (get_parent ()); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3610 Matrix parent_bb = obj.get_properties ().get_boundingbox (true); |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
3611 Matrix ext = get_extent (true, true); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3612 ext(1) = parent_bb(3) - ext(1) - ext(3); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3613 ext(0)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3614 ext(1)++; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3615 ext = convert_position (ext, "pixels", get_units (), |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3616 parent_bb.extract_n (0, 2, 1, 2)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3617 if (ext(0) < pos(0)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3618 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3619 pos(2) += pos(0)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3620 pos(0) = ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3621 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3622 if (ext(0)+ext(2) > pos(0)+pos(2)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3623 pos(2) = ext(0)+ext(2)-pos(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3624 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3625 if (ext(1) < pos(1)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3626 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3627 pos(3) += pos(1)-ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3628 pos(1) = ext(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3629 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3630 if (ext(1)+ext(3) > pos(1)+pos(3)) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3631 pos(3) = ext(1)+ext(3)-pos(1); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3632 return pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3633 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3634 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3635 void |
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
|
3636 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
|
3637 { |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3638 Matrix ref_linset = looseinset.get ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3639 if (autopos_tag_is ("subplot")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3640 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3641 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3642 if (parent_obj.isa ("figure")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3643 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3644 // FIXME: temporarily changed units should be protected |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3645 // from interrupts |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3646 std::string fig_units = parent_obj.get ("units").string_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3647 parent_obj.set ("units", "pixels"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3648 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3649 Matrix ref_outbox = outerposition.get ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3650 ref_outbox(2) += ref_outbox(0); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3651 ref_outbox(3) += ref_outbox(1); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3652 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3653 // Find those subplots that are left, right, bottom and top aligned |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3654 // with the current subplot |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3655 Matrix kids = parent_obj.get_properties ().get_children (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3656 std::vector<octave_value> aligned; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3657 std::vector<bool> l_aligned, b_aligned, r_aligned, t_aligned; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3658 for (octave_idx_type i = 0; i < kids.numel (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3659 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3660 graphics_object go = gh_manager::get_object (kids(i)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3661 if (go.isa ("axes")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3662 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3663 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3664 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3665 if (props.autopos_tag_is("subplot")) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3666 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3667 Matrix outpos = go.get ("outerposition").matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3668 bool l_align=(std::abs (outpos(0)-ref_outbox(0)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3669 bool b_align=(std::abs (outpos(1)-ref_outbox(1)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3670 bool r_align=(std::abs (outpos(0)+outpos(2)-ref_outbox(2)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3671 bool t_align=(std::abs (outpos(1)+outpos(3)-ref_outbox(3)) < 1e-15); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3672 if (l_align || b_align || r_align || t_align) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3673 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3674 aligned.push_back(kids(i)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3675 l_aligned.push_back(l_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3676 b_aligned.push_back(b_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3677 r_aligned.push_back(r_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3678 t_aligned.push_back(t_align); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3679 // FIXME: the temporarily deleted tags should be |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3680 // protected from interrupts |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3681 props.set_autopos_tag ("none"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3682 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3683 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3684 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3685 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3686 // Determine a minimum box which aligns the subplots |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3687 Matrix ref_box(1, 4, 0.); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3688 ref_box(2) = 1.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3689 ref_box(3) = 1.; |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3690 for (size_t i = 0; i < aligned.size (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3691 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3692 graphics_object go = gh_manager::get_object (aligned[i]); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3693 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3694 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3695 Matrix linset = props.get_looseinset ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3696 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3697 linset(0) = std::min (0., linset(0)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3698 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3699 linset(1) = std::min (0., linset(1)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3700 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3701 linset(2) = std::min (0., linset(2)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3702 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3703 linset(3) = std::min (0., linset(3)-0.01); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3704 props.set_looseinset (linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3705 Matrix pos = props.get_position ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3706 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3707 ref_box(0) = std::max (ref_box(0), pos(0)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3708 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3709 ref_box(1) = std::max (ref_box(1), pos(1)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3710 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3711 ref_box(2) = std::min (ref_box(2), pos(0)+pos(2)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3712 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3713 ref_box(3) = std::min (ref_box(3), pos(1)+pos(3)); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3714 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3715 // Set common looseinset values for all aligned subplots and |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3716 // revert their tag values |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3717 for (size_t i = 0; i < aligned.size (); i++) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3718 { |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3719 graphics_object go = gh_manager::get_object (aligned[i]); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3720 axes::properties& props = |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3721 dynamic_cast<axes::properties&> (go.get_properties ()); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3722 Matrix outpos = props.get_outerposition ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3723 Matrix linset = props.get_looseinset ().matrix_value (); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3724 if (l_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3725 linset(0) = (ref_box(0)-outpos(0))/outpos(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3726 if (b_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3727 linset(1) = (ref_box(1)-outpos(1))/outpos(3); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3728 if (r_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3729 linset(2) = (outpos(0)+outpos(2)-ref_box(2))/outpos(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3730 if (t_aligned[i]) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3731 linset(3) = (outpos(1)+outpos(3)-ref_box(3))/outpos(3); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3732 props.set_looseinset (linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3733 props.set_autopos_tag ("subplot"); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3734 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3735 parent_obj.set ("units", fig_units); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3736 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3737 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3738 else |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3739 sync_positions (ref_linset); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3740 } |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3741 |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3742 void |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3743 axes::properties::sync_positions (const Matrix& linset) |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3744 { |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3745 Matrix pos = position.get ().matrix_value (); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3746 Matrix outpos = outerposition.get ().matrix_value (); |
12685
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3747 double lratio = linset(0); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3748 double bratio = linset(1); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3749 double wratio = 1-linset(0)-linset(2); |
5cbf660e649d
Restructure subplot positioning and avoid labels overlap (bug #31610)
Konstantinos Poulios <logari81@googlemail.com>
parents:
12678
diff
changeset
|
3750 double hratio = 1-linset(1)-linset(3); |
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
|
3751 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
|
3752 { |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3753 pos = outpos; |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3754 pos(0) = outpos(0)+lratio*outpos(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3755 pos(1) = outpos(1)+bratio*outpos(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3756 pos(2) = wratio*outpos(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3757 pos(3) = hratio*outpos(3); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3758 |
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
|
3759 position = pos; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3760 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3761 Matrix tightpos = calc_tightbox (pos); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3762 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3763 double thrshldx = 0.005*outpos(2); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3764 double thrshldy = 0.005*outpos(3); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3765 double minsizex = 0.2*outpos(2); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3766 double minsizey = 0.2*outpos(3); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
3767 bool updatex = true, updatey = true; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3768 for (int i = 0; i < 10; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3769 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3770 double dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3771 bool modified = false; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3772 dt = outpos(0)+outpos(2)-tightpos(0)-tightpos(2); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3773 if (dt < -thrshldx && updatex) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3774 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3775 pos(2) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3776 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3777 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3778 dt = outpos(1)+outpos(3)-tightpos(1)-tightpos(3); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3779 if (dt < -thrshldy && updatey) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3780 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3781 pos(3) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3782 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3783 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3784 dt = outpos(0)-tightpos(0); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3785 if (dt > thrshldx && updatex) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3786 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3787 pos(0) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3788 pos(2) -= dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3789 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3790 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3791 dt = outpos(1)-tightpos(1); |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3792 if (dt > thrshldy && updatey) |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3793 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3794 pos(1) += dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3795 pos(3) -= dt; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3796 modified = true; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3797 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3798 |
12441
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3799 // Note: checking limit for minimum axes size |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3800 if (pos(2) < minsizex) |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3801 { |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3802 pos(0) -= 0.5*(minsizex-pos(2)); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3803 pos(2) = minsizex; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3804 updatex = false; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3805 } |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3806 if (pos(3) < minsizey) |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3807 { |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3808 pos(1) -= 0.5*(minsizey-pos(3)); |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3809 pos(3) = minsizey; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3810 updatey = false; |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3811 } |
b932ae4381da
improvements in synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12440
diff
changeset
|
3812 |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3813 if (modified) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3814 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3815 position = pos; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3816 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3817 tightpos = calc_tightbox (pos); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3818 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3819 else |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3820 break; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3821 } |
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
|
3822 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3823 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
|
3824 { |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3825 update_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3826 |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3827 outpos(0) = pos(0)-pos(2)*lratio/wratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3828 outpos(1) = pos(1)-pos(3)*bratio/hratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3829 outpos(2) = pos(2)/wratio; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
3830 outpos(3) = pos(3)/hratio; |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3831 |
12458
68daf2a0b56d
fix a small bug introduced on 2011-02-14
Konstantinos Poulios <logari81@googlemail.com>
parents:
12449
diff
changeset
|
3832 outerposition = calc_tightbox (outpos); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
3833 } |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3834 |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3835 Matrix inset (1, 4, 1.0); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3836 inset(0) = pos(0)-outpos(0); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3837 inset(1) = pos(1)-outpos(1); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3838 inset(2) = outpos(0)+outpos(2)-pos(0)-pos(2); |
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3839 inset(3) = outpos(1)+outpos(3)-pos(1)-pos(3); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
3840 |
12445
98772e4e8a2a
calculation of tightinset property
Konstantinos Poulios <logari81@googlemail.com>
parents:
12441
diff
changeset
|
3841 tightinset = inset; |
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
|
3842 } |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
3843 |
7363 | 3844 void |
8249 | 3845 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
|
3846 const std::string& who, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
3847 const octave_value& v) |
6962 | 3848 { |
10265
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3849 graphics_handle val; |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3850 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3851 if (v.is_string ()) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3852 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3853 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
|
3854 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3855 xset (val, "string", v); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3856 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3857 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3858 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3859 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
|
3860 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3861 if (go.isa ("text")) |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3862 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
|
3863 else |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3864 { |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3865 std::string cname = v.class_name (); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3866 |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3867 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
|
3868 who.c_str (), cname.c_str ()); |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3869 } |
8c583af2cf64
validate text object children of axes objects
John W. Eaton <jwe@octave.org>
parents:
10160
diff
changeset
|
3870 } |
6962 | 3871 |
6874 | 3872 if (! error_state) |
3873 { | |
8249 | 3874 xset (val, "handlevisibility", "off"); |
3875 | |
3876 gh_manager::free (hp.handle_value ()); | |
3877 | |
3878 base_properties::remove_child (hp.handle_value ()); | |
3879 | |
3880 hp = val; | |
3881 | |
3882 adopt (hp.handle_value ()); | |
6874 | 3883 } |
3884 } | |
3885 | |
3886 void | |
7363 | 3887 axes::properties::set_xlabel (const octave_value& v) |
6874 | 3888 { |
8249 | 3889 set_text_child (xlabel, "xlabel", v); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3890 xset (xlabel.handle_value (), "positionmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3891 xset (xlabel.handle_value (), "rotationmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3892 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3893 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3894 xset (xlabel.handle_value (), "clipping", "off"); |
11598
62b7ea59a6ff
fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents:
11586
diff
changeset
|
3895 xset (xlabel.handle_value (), "color", get_xcolor ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3896 xset (xlabel.handle_value (), "autopos_tag", "xlabel"); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
3897 update_xlabel_position (); |
6874 | 3898 } |
3899 | |
3900 void | |
7363 | 3901 axes::properties::set_ylabel (const octave_value& v) |
6874 | 3902 { |
8249 | 3903 set_text_child (ylabel, "ylabel", v); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3904 xset (ylabel.handle_value (), "positionmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3905 xset (ylabel.handle_value (), "rotationmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3906 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3907 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3908 xset (ylabel.handle_value (), "clipping", "off"); |
11598
62b7ea59a6ff
fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents:
11586
diff
changeset
|
3909 xset (ylabel.handle_value (), "color", get_ycolor ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3910 xset (ylabel.handle_value (), "autopos_tag", "ylabel"); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
3911 update_ylabel_position (); |
6874 | 3912 } |
3913 | |
3914 void | |
7363 | 3915 axes::properties::set_zlabel (const octave_value& v) |
6874 | 3916 { |
8249 | 3917 set_text_child (zlabel, "zlabel", v); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3918 xset (zlabel.handle_value (), "positionmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3919 xset (zlabel.handle_value (), "rotationmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3920 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3921 xset (zlabel.handle_value (), "verticalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3922 xset (zlabel.handle_value (), "clipping", "off"); |
11598
62b7ea59a6ff
fixing color mismatch between axis and axis label
Konstantinos Poulios <logari81@googlemail.com>
parents:
11586
diff
changeset
|
3923 xset (zlabel.handle_value (), "color", get_zcolor ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3924 xset (zlabel.handle_value (), "autopos_tag", "zlabel"); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
3925 update_zlabel_position (); |
8249 | 3926 } |
3927 | |
3928 void | |
3929 axes::properties::set_title (const octave_value& v) | |
3930 { | |
3931 set_text_child (title, "title", v); | |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3932 xset (title.handle_value (), "positionmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3933 xset (title.handle_value (), "horizontalalignment", "center"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3934 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3935 xset (title.handle_value (), "verticalalignment", "bottom"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3936 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
3937 xset (title.handle_value (), "clipping", "off"); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
3938 xset (title.handle_value (), "autopos_tag", "title"); |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
3939 update_title_position (); |
6874 | 3940 } |
3941 | |
3942 void | |
6844 | 3943 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
|
3944 const std::string& mode) |
6705 | 3945 { |
3946 box = "on"; | |
6962 | 3947 colororder = default_colororder (); |
6705 | 3948 dataaspectratio = Matrix (1, 3, 1.0); |
3949 dataaspectratiomode = "auto"; | |
7363 | 3950 layer = "bottom"; |
6705 | 3951 |
3952 Matrix tlim (1, 2, 0.0); | |
3953 tlim(1) = 1; | |
3954 xlim = tlim; | |
3955 ylim = tlim; | |
3956 zlim = tlim; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3957 |
6807 | 3958 Matrix cl (1, 2, 0); |
3959 cl(1) = 1; | |
3960 clim = cl; | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
3961 |
7363 | 3962 xlimmode = "auto"; |
3963 ylimmode = "auto"; | |
3964 zlimmode = "auto"; | |
3965 climmode = "auto"; | |
8208 | 3966 |
6705 | 3967 xgrid = "off"; |
3968 ygrid = "off"; | |
3969 zgrid = "off"; | |
3970 xminorgrid = "off"; | |
3971 yminorgrid = "off"; | |
3972 zminorgrid = "off"; | |
3973 xtick = Matrix (); | |
3974 ytick = Matrix (); | |
3975 ztick = Matrix (); | |
3976 xtickmode = "auto"; | |
3977 ytickmode = "auto"; | |
3978 ztickmode = "auto"; | |
3979 xticklabel = ""; | |
3980 yticklabel = ""; | |
3981 zticklabel = ""; | |
3982 xticklabelmode = "auto"; | |
3983 yticklabelmode = "auto"; | |
3984 zticklabelmode = "auto"; | |
10565
2880a862b1a8
Make the default axes color none (bug #29060)
David Bateman <dbateman@free.fr>
parents:
10553
diff
changeset
|
3985 color = "none"; |
7364 | 3986 xcolor = color_values ("black"); |
3987 ycolor = color_values ("black"); | |
3988 zcolor = color_values ("black"); | |
7363 | 3989 xscale = "linear"; |
3990 yscale = "linear"; | |
3991 zscale = "linear"; | |
6705 | 3992 xdir = "normal"; |
3993 ydir = "normal"; | |
3994 zdir = "normal"; | |
7363 | 3995 yaxislocation = "left"; |
3996 xaxislocation = "bottom"; | |
6705 | 3997 |
7427 | 3998 // Note: camera properties will be set through update_transform |
3999 camerapositionmode = "auto"; | |
4000 cameratargetmode = "auto"; | |
4001 cameraupvectormode = "auto"; | |
4002 cameraviewanglemode = "auto"; | |
4003 plotboxaspectratio = Matrix (1, 3, 1.0); | |
4004 drawmode = "normal"; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4005 gridlinestyle = ":"; |
7427 | 4006 linestyleorder = "-"; |
4007 linewidth = 0.5; | |
7820
cb4838d70ab2
Fix default value for axes gridlinestyle and minorgridlinestyle.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7680
diff
changeset
|
4008 minorgridlinestyle = ":"; |
7427 | 4009 // Note: plotboxaspectratio will be set through update_aspectratiors |
4010 plotboxaspectratiomode = "auto"; | |
4011 projection = "orthographic"; | |
4012 tickdir = "in"; | |
4013 tickdirmode = "auto"; | |
8740
cb0ea772a4af
Initialize axes ticklength property.
Ben Abbott <bpabbott@mac.com>
parents:
8687
diff
changeset
|
4014 ticklength = default_axes_ticklength (); |
7427 | 4015 tightinset = Matrix (1, 4, 0.0); |
4016 | |
4017 sx = "linear"; | |
4018 sy = "linear"; | |
4019 sz = "linear"; | |
4020 | |
6705 | 4021 Matrix tview (1, 2, 0.0); |
4022 tview(1) = 90; | |
4023 view = tview; | |
4024 | |
6765 | 4025 visible = "on"; |
6705 | 4026 nextplot = "replace"; |
4027 | |
4028 if (mode != "replace") | |
4029 { | |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4030 fontangle = "normal"; |
8944
cb0e9facc342
make default fontname * instead of Helvetica
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
4031 fontname = OCTAVE_DEFAULT_FONTNAME; |
11384
1511bbfe6a6e
Change axes default fontsize from 12 to 10.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11283
diff
changeset
|
4032 fontsize = 10; |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4033 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
|
4034 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
|
4035 |
6406 | 4036 Matrix touterposition (1, 4, 0.0); |
4037 touterposition(2) = 1; | |
4038 touterposition(3) = 1; | |
4039 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
|
4040 |
67edbcb19665
rudimentry (i.e. no font metrics) sync of axes.position and axes.outerposition
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7859
diff
changeset
|
4041 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
|
4042 |
12467
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4043 Matrix tlooseinset = default_axes_position (); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4044 tlooseinset(2) = 1-tlooseinset(0)-tlooseinset(2); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4045 tlooseinset(3) = 1-tlooseinset(1)-tlooseinset(3); |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4046 looseinset = tlooseinset; |
2f83974d5a6d
implement looseinset property for axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12458
diff
changeset
|
4047 |
8228
53dbbd331498
Preserve font and position properties when axes are replace in the handle code
David Bateman <dbateman@free.fr>
parents:
8209
diff
changeset
|
4048 activepositionproperty = "outerposition"; |
6406 | 4049 } |
4050 | |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
4051 delete_children (true); |
6432 | 4052 |
8249 | 4053 xlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); |
4054 ylabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
4055 zlabel = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
4056 title = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
4057 | |
4058 xset (xlabel.handle_value (), "handlevisibility", "off"); | |
4059 xset (ylabel.handle_value (), "handlevisibility", "off"); | |
4060 xset (zlabel.handle_value (), "handlevisibility", "off"); | |
4061 xset (title.handle_value (), "handlevisibility", "off"); | |
4062 | |
8636 | 4063 xset (xlabel.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4064 xset (xlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4065 xset (ylabel.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4066 xset (ylabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4067 xset (zlabel.handle_value (), "horizontalalignment", "right"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4068 xset (zlabel.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4069 xset (title.handle_value (), "horizontalalignment", "center"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4070 xset (title.handle_value (), "horizontalalignmentmode", "auto"); |
8636 | 4071 |
4072 xset (xlabel.handle_value (), "verticalalignment", "cap"); | |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4073 xset (xlabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4074 xset (ylabel.handle_value (), "verticalalignment", "bottom"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4075 xset (ylabel.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4076 xset (title.handle_value (), "verticalalignment", "bottom"); |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4077 xset (title.handle_value (), "verticalalignmentmode", "auto"); |
8636 | 4078 |
4079 xset (ylabel.handle_value (), "rotation", 90.0); | |
11385
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4080 xset (ylabel.handle_value (), "rotationmode", "auto"); |
71e7467fbd34
Disable auto-positioning of manually positioned title and axes labels.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11384
diff
changeset
|
4081 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4082 xset (zlabel.handle_value (), "visible", "off"); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4083 |
9403
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4084 xset (xlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4085 xset (ylabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4086 xset (zlabel.handle_value (), "clipping", "off"); |
4af6e29449c1
[mq]: graphics_text_engine
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9396
diff
changeset
|
4087 xset (title.handle_value (), "clipping", "off"); |
8636 | 4088 |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4089 xset (xlabel.handle_value (), "autopos_tag", "xlabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4090 xset (ylabel.handle_value (), "autopos_tag", "ylabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4091 xset (zlabel.handle_value (), "autopos_tag", "zlabel"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4092 xset (title.handle_value (), "autopos_tag", "title"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4093 |
8249 | 4094 adopt (xlabel.handle_value ()); |
4095 adopt (ylabel.handle_value ()); | |
4096 adopt (zlabel.handle_value ()); | |
4097 adopt (title.handle_value ()); | |
4098 | |
7427 | 4099 update_transform (); |
4100 | |
6705 | 4101 override_defaults (obj); |
4102 } | |
4103 | |
8208 | 4104 void |
4105 axes::properties::delete_text_child (handle_property& hp) | |
6874 | 4106 { |
8208 | 4107 graphics_handle h = hp.handle_value (); |
4108 | |
4109 if (h.ok ()) | |
4110 { | |
4111 graphics_object go = gh_manager::get_object (h); | |
4112 | |
4113 if (go.valid_object ()) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4114 gh_manager::free (h); |
8249 | 4115 |
4116 base_properties::remove_child (h); | |
8208 | 4117 } |
4118 | |
8249 | 4119 // FIXME -- is it necessary to check whether the axes object is |
4120 // being deleted now? I think this function is only called when an | |
4121 // individual child object is delete and not when the parent axes | |
4122 // object is deleted. | |
4123 | |
8208 | 4124 if (! is_beingdeleted ()) |
8249 | 4125 { |
4126 hp = gh_manager::make_graphics_handle ("text", __myhandle__, false); | |
4127 | |
4128 xset (hp.handle_value (), "handlevisibility", "off"); | |
4129 | |
4130 adopt (hp.handle_value ()); | |
4131 } | |
6705 | 4132 } |
6406 | 4133 |
6705 | 4134 void |
6844 | 4135 axes::properties::remove_child (const graphics_handle& h) |
6705 | 4136 { |
8249 | 4137 if (xlabel.handle_value ().ok () && h == xlabel.handle_value ()) |
8208 | 4138 delete_text_child (xlabel); |
7363 | 4139 else if (ylabel.handle_value ().ok () && h == ylabel.handle_value ()) |
8208 | 4140 delete_text_child (ylabel); |
7363 | 4141 else if (zlabel.handle_value ().ok () && h == zlabel.handle_value ()) |
8208 | 4142 delete_text_child (zlabel); |
8249 | 4143 else if (title.handle_value ().ok () && h == title.handle_value ()) |
4144 delete_text_child (title); | |
6705 | 4145 else |
4146 base_properties::remove_child (h); | |
4147 } | |
6406 | 4148 |
7427 | 4149 inline Matrix |
4150 xform_matrix (void) | |
4151 { | |
4152 Matrix m (4, 4, 0.0); | |
4153 for (int i = 0; i < 4; i++) | |
4154 m(i,i) = 1; | |
4155 return m; | |
4156 } | |
4157 | |
4158 inline ColumnVector | |
4159 xform_vector (void) | |
4160 { | |
4161 ColumnVector v (4, 0.0); | |
4162 v(3) = 1; | |
4163 return v; | |
4164 } | |
4165 | |
4166 inline ColumnVector | |
4167 xform_vector (double x, double y, double z) | |
4168 { | |
4169 ColumnVector v (4, 1.0); | |
4170 v(0) = x; v(1) = y; v(2) = z; | |
4171 return v; | |
4172 } | |
4173 | |
4174 inline ColumnVector | |
4175 transform (const Matrix& m, double x, double y, double z) | |
4176 { | |
4177 return (m * xform_vector (x, y, z)); | |
4178 } | |
4179 | |
4180 inline Matrix | |
4181 xform_scale (double x, double y, double z) | |
4182 { | |
4183 Matrix m (4, 4, 0.0); | |
4184 m(0,0) = x; m(1,1) = y; m(2,2) = z; m(3,3) = 1; | |
4185 return m; | |
4186 } | |
4187 | |
4188 inline Matrix | |
4189 xform_translate (double x, double y, double z) | |
4190 { | |
4191 Matrix m = xform_matrix (); | |
4192 m(0,3) = x; m(1,3) = y; m(2,3) = z; m(3,3) = 1; | |
4193 return m; | |
4194 } | |
4195 | |
4196 inline void | |
4197 scale (Matrix& m, double x, double y, double z) | |
4198 { | |
4199 m = m * xform_scale (x, y, z); | |
4200 } | |
4201 | |
4202 inline void | |
4203 translate (Matrix& m, double x, double y, double z) | |
4204 { | |
4205 m = m * xform_translate (x, y, z); | |
4206 } | |
4207 | |
4208 inline void | |
4209 xform (ColumnVector& v, const Matrix& m) | |
4210 { | |
4211 v = m*v; | |
4212 } | |
4213 | |
4214 inline void | |
4215 scale (ColumnVector& v, double x, double y, double z) | |
4216 { | |
4217 v(0) *= x; | |
4218 v(1) *= y; | |
4219 v(2) *= z; | |
4220 } | |
4221 | |
4222 inline void | |
4223 translate (ColumnVector& v, double x, double y, double z) | |
4224 { | |
4225 v(0) += x; | |
4226 v(1) += y; | |
4227 v(2) += z; | |
4228 } | |
4229 | |
4230 inline void | |
4231 normalize (ColumnVector& v) | |
4232 { | |
4233 double fact = 1.0/sqrt(v(0)*v(0)+v(1)*v(1)+v(2)*v(2)); | |
4234 scale (v, fact, fact, fact); | |
4235 } | |
4236 | |
4237 inline double | |
4238 dot (const ColumnVector& v1, const ColumnVector& v2) | |
4239 { | |
4240 return (v1(0)*v2(0)+v1(1)*v2(1)+v1(2)*v2(2)); | |
4241 } | |
4242 | |
4243 inline double | |
4244 norm (const ColumnVector& v) | |
4245 { | |
4246 return sqrt (dot (v, v)); | |
4247 } | |
4248 | |
4249 inline ColumnVector | |
4250 cross (const ColumnVector& v1, const ColumnVector& v2) | |
4251 { | |
4252 ColumnVector r = xform_vector (); | |
4253 r(0) = v1(1)*v2(2)-v1(2)*v2(1); | |
4254 r(1) = v1(2)*v2(0)-v1(0)*v2(2); | |
4255 r(2) = v1(0)*v2(1)-v1(1)*v2(0); | |
4256 return r; | |
4257 } | |
4258 | |
4259 inline Matrix | |
4260 unit_cube (void) | |
4261 { | |
4262 static double data[32] = { | |
4263 0,0,0,1, | |
4264 1,0,0,1, | |
4265 0,1,0,1, | |
4266 0,0,1,1, | |
4267 1,1,0,1, | |
4268 1,0,1,1, | |
4269 0,1,1,1, | |
4270 1,1,1,1}; | |
4271 Matrix m (4, 8); | |
4272 memcpy (m.fortran_vec (), data, sizeof(double)*32); | |
4273 return m; | |
4274 } | |
4275 | |
4276 inline ColumnVector | |
4277 cam2xform (const Array<double>& m) | |
4278 { | |
4279 ColumnVector retval (4, 1.0); | |
4280 memcpy (retval.fortran_vec (), m.fortran_vec (), sizeof(double)*3); | |
4281 return retval; | |
4282 } | |
4283 | |
4284 inline RowVector | |
4285 xform2cam (const ColumnVector& v) | |
4286 { | |
4287 return v.extract_n (0, 3).transpose (); | |
4288 } | |
4289 | |
4290 void | |
4291 axes::properties::update_camera (void) | |
4292 { | |
4293 double xd = (xdir_is ("normal") ? 1 : -1); | |
4294 double yd = (ydir_is ("normal") ? 1 : -1); | |
4295 double zd = (zdir_is ("normal") ? 1 : -1); | |
4296 | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4297 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
|
4298 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
|
4299 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
|
4300 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4301 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
|
4302 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
|
4303 double zo = zlimits(zd > 0 ? 0 : 1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4304 |
7427 | 4305 Matrix pb = get_plotboxaspectratio ().matrix_value (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4306 |
7427 | 4307 bool autocam = (camerapositionmode_is ("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4308 && cameratargetmode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4309 && cameraupvectormode_is ("auto") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4310 && cameraviewanglemode_is ("auto")); |
7427 | 4311 bool dowarp = (autocam && dataaspectratiomode_is("auto") |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4312 && plotboxaspectratiomode_is ("auto")); |
7427 | 4313 |
4314 ColumnVector c_eye (xform_vector ()); | |
4315 ColumnVector c_center (xform_vector ()); | |
4316 ColumnVector c_upv (xform_vector ()); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4317 |
7427 | 4318 if (cameratargetmode_is ("auto")) |
4319 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4320 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
|
4321 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
|
4322 c_center(2) = (zlimits(0)+zlimits(1))/2; |
7427 | 4323 |
4324 cameratarget = xform2cam (c_center); | |
4325 } | |
4326 else | |
4327 c_center = cam2xform (get_cameratarget ().matrix_value ()); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4328 |
7427 | 4329 if (camerapositionmode_is ("auto")) |
4330 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4331 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
|
4332 double az = tview(0), el = tview(1); |
7427 | 4333 double d = 5*sqrt(pb(0)*pb(0)+pb(1)*pb(1)+pb(2)*pb(2)); |
4334 | |
4335 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4336 c_eye(2) = d*signum(el); |
7427 | 4337 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4338 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4339 az *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4340 el *= M_PI/180.0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4341 c_eye(0) = d*cos(el)*sin(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4342 c_eye(1) = -d*cos(el)*cos(az); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4343 c_eye(2) = d*sin(el); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4344 } |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4345 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
|
4346 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
|
4347 c_eye(2) = c_eye(2)*(zlimits(1)-zlimits(0))/(zd*pb(2))+c_center(2); |
7427 | 4348 |
4349 cameraposition = xform2cam (c_eye); | |
4350 } | |
4351 else | |
4352 c_eye = cam2xform (get_cameraposition ().matrix_value ()); | |
4353 | |
4354 if (cameraupvectormode_is ("auto")) | |
4355 { | |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
4356 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
|
4357 double az = tview(0), el = tview(1); |
7427 | 4358 |
4359 if (el == 90 || el == -90) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4360 { |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4361 c_upv(0) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4362 -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
|
4363 c_upv(1) = |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
4364 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
|
4365 } |
7427 | 4366 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4367 c_upv(2) = 1; |
7427 | 4368 |
4369 cameraupvector = xform2cam (c_upv); | |
4370 } | |
4371 else | |
4372 c_upv = cam2xform (get_cameraupvector ().matrix_value ()); | |
4373 | |
4374 Matrix x_view = xform_matrix (); | |
4375 Matrix x_projection = xform_matrix (); | |
4376 Matrix x_viewport = xform_matrix (); | |
4377 Matrix x_normrender = xform_matrix (); | |
4378 Matrix x_pre = xform_matrix (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4379 |
7427 | 4380 x_render = xform_matrix (); |
4381 x_render_inv = xform_matrix (); | |
4382 | |
4383 scale (x_pre, pb(0), pb(1), pb(2)); | |
4384 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
|
4385 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
|
4386 zd/(zlimits(1)-zlimits(0))); |
7427 | 4387 translate (x_pre, -xo, -yo, -zo); |
4388 | |
4389 xform (c_eye, x_pre); | |
4390 xform (c_center, x_pre); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
4391 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
|
4392 pb(2)/(zlimits(1)-zlimits(0))); |
7427 | 4393 translate (c_center, -c_eye(0), -c_eye(1), -c_eye(2)); |
4394 | |
4395 ColumnVector F (c_center), f (F), UP (c_upv); | |
4396 normalize (f); | |
4397 normalize (UP); | |
4398 | |
7440 | 4399 if (std::abs (dot (f, UP)) > 1e-15) |
7427 | 4400 { |
4401 double fa = 1/sqrt(1-f(2)*f(2)); | |
4402 scale (UP, fa, fa, fa); | |
4403 } | |
4404 | |
4405 ColumnVector s = cross (f, UP); | |
4406 ColumnVector u = cross (s, f); | |
4407 | |
4408 scale (x_view, 1, 1, -1); | |
4409 Matrix l = xform_matrix (); | |
4410 l(0,0) = s(0); l(0,1) = s(1); l(0,2) = s(2); | |
4411 l(1,0) = u(0); l(1,1) = u(1); l(1,2) = u(2); | |
4412 l(2,0) = -f(0); l(2,1) = -f(1); l(2,2) = -f(2); | |
4413 x_view = x_view * l; | |
4414 translate (x_view, -c_eye(0), -c_eye(1), -c_eye(2)); | |
4415 scale (x_view, pb(0), pb(1), pb(2)); | |
4416 translate (x_view, -0.5, -0.5, -0.5); | |
4417 | |
4418 Matrix x_cube = x_view * unit_cube (); | |
4419 ColumnVector cmin = x_cube.row_min (), cmax = x_cube.row_max (); | |
4420 double xM = cmax(0)-cmin(0); | |
4421 double yM = cmax(1)-cmin(1); | |
4422 | |
7447 | 4423 Matrix bb = get_boundingbox (true); |
7427 | 4424 |
4425 double v_angle; | |
4426 | |
4427 if (cameraviewanglemode_is ("auto")) | |
4428 { | |
4429 double af; | |
4430 | |
8333 | 4431 // FIXME -- was this really needed? When compared to Matlab, it |
7427 | 4432 // does not seem to be required. Need investigation with concrete |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
4433 // graphics toolkit to see results visually. |
7427 | 4434 if (false && dowarp) |
4435 af = 1.0 / (xM > yM ? xM : yM); | |
4436 else | |
4437 { | |
4438 if ((bb(2)/bb(3)) > (xM/yM)) | |
4439 af = 1.0 / yM; | |
4440 else | |
4441 af = 1.0 / xM; | |
4442 } | |
4443 v_angle = 2 * (180.0 / M_PI) * atan (1 / (2 * af * norm (F))); | |
4444 | |
4445 cameraviewangle = v_angle; | |
4446 } | |
4447 else | |
4448 v_angle = get_cameraviewangle (); | |
4449 | |
4450 double pf = 1 / (2 * tan ((v_angle / 2) * M_PI / 180.0) * norm (F)); | |
4451 scale (x_projection, pf, pf, 1); | |
4452 | |
4453 if (dowarp) | |
4454 { | |
4455 xM *= pf; | |
4456 yM *= pf; | |
7447 | 4457 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 4458 scale (x_viewport, bb(2)/xM, -bb(3)/yM, 1); |
4459 } | |
4460 else | |
4461 { | |
4462 double pix = 1; | |
4463 if (autocam) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4464 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4465 if ((bb(2)/bb(3)) > (xM/yM)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4466 pix = bb(3); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4467 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4468 pix = bb(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4469 } |
7427 | 4470 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
4471 pix = (bb(2) < bb(3) ? bb(2) : bb(3)); |
7447 | 4472 translate (x_viewport, bb(0)+bb(2)/2, bb(1)+bb(3)/2, 0); |
7427 | 4473 scale (x_viewport, pix, -pix, 1); |
4474 } | |
4475 | |
4476 x_normrender = x_viewport * x_projection * x_view; | |
4477 | |
4478 x_cube = x_normrender * unit_cube (); | |
4479 cmin = x_cube.row_min (); | |
4480 cmax = x_cube.row_max (); | |
4481 x_zlim.resize (1, 2); | |
4482 x_zlim(0) = cmin(2); | |
4483 x_zlim(1) = cmax(2); | |
4484 | |
4485 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
|
4486 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
|
4487 zd/(zlimits(1)-zlimits(0))); |
7427 | 4488 translate (x_render, -xo, -yo, -zo); |
4489 | |
4490 x_viewtransform = x_view; | |
4491 x_projectiontransform = x_projection; | |
4492 x_viewporttransform = x_viewport; | |
4493 x_normrendertransform = x_normrender; | |
4494 x_rendertransform = x_render; | |
4495 | |
4496 x_render_inv = x_render.inverse (); | |
4497 | |
4498 // Note: these matrices are a slight modified version of the regular | |
4499 // matrices, more suited for OpenGL rendering (x_gl_mat1 => light | |
4500 // => x_gl_mat2) | |
4501 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
|
4502 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
|
4503 zd/(zlimits(1)-zlimits(0))); |
7427 | 4504 translate (x_gl_mat1, -xo, -yo, -zo); |
4505 x_gl_mat2 = x_viewport * x_projection; | |
4506 } | |
4507 | |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4508 static bool updating_axes_layout = false; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4509 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4510 void |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4511 axes::properties::update_axes_layout (void) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4512 { |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4513 if (updating_axes_layout) |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4514 return; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4515 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4516 graphics_xform xform = get_transform (); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4517 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4518 double xd = (xdir_is ("normal") ? 1 : -1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4519 double yd = (ydir_is ("normal") ? 1 : -1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4520 double zd = (zdir_is ("normal") ? 1 : -1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4521 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4522 const Matrix xlims = xform.xscale (get_xlim ().matrix_value ()); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4523 const Matrix ylims = xform.yscale (get_ylim ().matrix_value ()); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4524 const Matrix zlims = xform.zscale (get_zlim ().matrix_value ()); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4525 double x_min = xlims(0), x_max = xlims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4526 double y_min = ylims(0), y_max = ylims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4527 double z_min = zlims(0), z_max = zlims(1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4528 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4529 ColumnVector p1, p2, dir (3); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4530 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4531 xstate = ystate = zstate = AXE_ANY_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4532 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4533 p1 = xform.transform (x_min, (y_min+y_max)/2, (z_min+z_max)/2, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4534 p2 = xform.transform (x_max, (y_min+y_max)/2, (z_min+z_max)/2, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4535 dir(0) = xround (p2(0)-p1(0)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4536 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4537 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4538 if (dir(0) == 0 && dir(1) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4539 xstate = AXE_DEPTH_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4540 else if (dir(2) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4541 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4542 if (dir(0) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4543 xstate = AXE_VERT_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4544 else if (dir(1) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4545 xstate = AXE_HORZ_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4546 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4547 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4548 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4549 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4550 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4551 xPlane = (dir(0) > 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4552 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4553 xPlane = (dir(1) < 0 ? x_max : x_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4554 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4555 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4556 xPlane = (dir(2) < 0 ? x_min : x_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4557 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4558 xPlaneN = (xPlane == x_min ? x_max : x_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4559 fx = (x_max-x_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4560 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4561 p1 = xform.transform ((x_min+x_max)/2, y_min, (z_min+z_max)/2, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4562 p2 = xform.transform ((x_min+x_max)/2, y_max, (z_min+z_max)/2, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4563 dir(0) = xround (p2(0)-p1(0)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4564 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4565 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4566 if (dir(0) == 0 && dir(1) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4567 ystate = AXE_DEPTH_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4568 else if (dir(2) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4569 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4570 if (dir(0) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4571 ystate = AXE_VERT_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4572 else if (dir(1) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4573 ystate = AXE_HORZ_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4574 } |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4575 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4576 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4577 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4578 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4579 yPlane = (dir(0) > 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4580 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4581 yPlane = (dir(1) < 0 ? y_max : y_min); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4582 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4583 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4584 yPlane = (dir(2) < 0 ? y_min : y_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4585 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4586 yPlaneN = (yPlane == y_min ? y_max : y_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4587 fy = (y_max-y_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4588 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4589 p1 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_min, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4590 p2 = xform.transform((x_min+x_max)/2, (y_min+y_max)/2, z_max, false); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4591 dir(0) = xround(p2(0)-p1(0)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4592 dir(1) = xround (p2(1)-p1(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4593 dir(2) = (p2(2)-p1(2)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4594 if (dir(0) == 0 && dir(1) == 0) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4595 zstate = AXE_DEPTH_DIR; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4596 else if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4597 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4598 if (dir(0) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4599 zstate = AXE_VERT_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4600 else if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4601 zstate = AXE_HORZ_DIR; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4602 } |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4603 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4604 if (dir(2) == 0) |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4605 { |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4606 if (dir(1) == 0) |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4607 zPlane = (dir(0) > 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4608 else |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4609 zPlane = (dir(1) < 0 ? z_min : z_max); |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4610 } |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4611 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4612 zPlane = (dir(2) < 0 ? z_min : z_max); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4613 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4614 zPlaneN = (zPlane == z_min ? z_max : z_min); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4615 fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4616 |
12347
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4617 unwind_protect frame; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4618 frame.protect_var (updating_axes_layout); |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4619 updating_axes_layout = true; |
f6763ab98609
Prevent race condition in update_axes_layout
Konstantinos Poulios <logari81@googlemail.com>
parents:
12334
diff
changeset
|
4620 |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4621 update_ticklengths (); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4622 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4623 xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4624 zSign = (zd*(zPlane-zPlaneN) <= 0); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4625 xyzSym = zSign ? xySym : !xySym; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4626 xpTick = (zSign ? xPlaneN : xPlane); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4627 ypTick = (zSign ? yPlaneN : yPlane); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4628 zpTick = (zSign ? zPlane : zPlaneN); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4629 xpTickN = (zSign ? xPlane : xPlaneN); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4630 ypTickN = (zSign ? yPlane : yPlaneN); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4631 zpTickN = (zSign ? zPlaneN : zPlane); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4632 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4633 /* 2D mode */ |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4634 x2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4635 y2Dright = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4636 layer2Dtop = false; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4637 if (xstate == AXE_HORZ_DIR && ystate == AXE_VERT_DIR) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4638 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4639 if (xaxislocation_is ("top")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4640 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4641 double tmp = yPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4642 yPlane = yPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4643 yPlaneN = tmp; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4644 x2Dtop = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4645 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4646 ypTick = yPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4647 ypTickN = yPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4648 if (yaxislocation_is ("right")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4649 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4650 double tmp = xPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4651 xPlane = xPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4652 xPlaneN = tmp; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4653 y2Dright = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4654 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4655 xpTick = xPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4656 xpTickN = xPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4657 if (layer_is ("top")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4658 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4659 zpTick = zPlaneN; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4660 layer2Dtop = true; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4661 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4662 else |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4663 zpTick = zPlane; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4664 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4665 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4666 Matrix viewmat = get_view ().matrix_value (); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4667 nearhoriz = std::abs(viewmat(1)) <= 5; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4668 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4669 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4670 void |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4671 axes::properties::update_ticklengths (void) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4672 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4673 bool mode2d = (((xstate > AXE_DEPTH_DIR ? 1 : 0) + |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4674 (ystate > AXE_DEPTH_DIR ? 1 : 0) + |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4675 (zstate > AXE_DEPTH_DIR ? 1 : 0)) == 2); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4676 if (tickdirmode_is ("auto")) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4677 { |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4678 // FIXME: tickdir should be updated (code below comes |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4679 // from JHandles) |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4680 //autoMode++; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4681 //TickDir.set(mode2d ? "in" : "out", true); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4682 //autoMode--; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4683 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4684 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4685 //double ticksign = (tickdir_is ("in") ? -1 : 1); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4686 double ticksign = (tickdirmode_is ("auto") ? |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4687 (mode2d ? -1 : 1) : |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4688 (tickdir_is ("in") ? -1 : 1)); |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4689 // FIXME: use ticklength property |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4690 xticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4691 yticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4692 zticklen = ticksign*7; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4693 |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4694 xtickoffset = (mode2d ? std::max (0., xticklen) : std::abs (xticklen)) + 5; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4695 ytickoffset = (mode2d ? std::max (0., yticklen) : std::abs (yticklen)) + 5; |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
4696 ztickoffset = (mode2d ? std::max (0., zticklen) : std::abs (zticklen)) + 5; |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4697 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4698 update_xlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4699 update_ylabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4700 update_zlabel_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4701 update_title_position (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4702 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4703 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4704 static bool updating_xlabel_position = false; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4705 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4706 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4707 axes::properties::update_xlabel_position (void) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4708 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4709 if (updating_xlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4710 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4711 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4712 text::properties& xlabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4713 (gh_manager::get_object (get_xlabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4714 |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
4715 bool is_empty = xlabel_props.get_string ().is_empty (); |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4716 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4717 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4718 frame.protect_var (updating_xlabel_position); |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4719 updating_xlabel_position = true; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4720 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4721 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4722 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4723 if (xlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4724 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4725 xlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4726 (xstate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4727 ? "center" : (xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4728 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4729 xlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4730 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4731 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4732 if (xlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4733 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4734 xlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4735 (xstate == AXE_VERT_DIR || x2Dtop ? "bottom" : "top"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4736 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4737 xlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4738 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4739 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4740 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4741 if (xlabel_props.positionmode_is ("auto") |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4742 || xlabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4743 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4744 graphics_xform xform = get_transform (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4745 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4746 Matrix ext (1, 2, 0.0); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4747 ext = get_ticklabel_extents (get_xtick ().matrix_value (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4748 get_xticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4749 get_xlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4750 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4751 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4752 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4753 graphics_xform::xform_vector ((xpTickN+xpTick)/2, ypTick, zpTick); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4754 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4755 bool tick_along_z = nearhoriz || xisinf (fy); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4756 if (tick_along_z) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4757 p(2) += (signum(zpTick-zpTickN)*fz*xtickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4758 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4759 p(1) += (signum(ypTick-ypTickN)*fy*xtickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4760 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4761 p = xform.transform (p(0), p(1), p(2), false); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4762 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4763 switch (xstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4764 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4765 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4766 p(0) += (xyzSym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4767 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4768 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4769 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4770 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4771 p(0) -= wmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4772 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4773 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4774 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4775 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4776 p(1) += (x2Dtop ? -hmax : hmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4777 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4778 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4779 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4780 if (xlabel_props.positionmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4781 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4782 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4783 xlabel_props.set_position (p.extract_n (0, 3).transpose ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4784 xlabel_props.set_positionmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4785 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4786 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4787 if (! is_empty && xlabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4788 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4789 xlabel_props.set_rotation (angle); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4790 xlabel_props.set_rotationmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4791 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4792 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4793 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4794 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4795 static bool updating_ylabel_position = false; |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4796 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4797 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4798 axes::properties::update_ylabel_position (void) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4799 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4800 if (updating_ylabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4801 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4802 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4803 text::properties& ylabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4804 (gh_manager::get_object (get_ylabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4805 |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
4806 bool is_empty = ylabel_props.get_string ().is_empty (); |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4807 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4808 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4809 frame.protect_var (updating_ylabel_position); |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4810 updating_ylabel_position = true; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4811 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4812 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4813 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4814 if (ylabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4815 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4816 ylabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4817 (ystate > AXE_DEPTH_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4818 ? "center" : (!xyzSym ? "left" : "right")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4819 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4820 ylabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4821 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4822 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4823 if (ylabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4824 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4825 ylabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4826 (ystate == AXE_VERT_DIR && !y2Dright ? "bottom" : "top"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4827 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4828 ylabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4829 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4830 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4831 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4832 if (ylabel_props.positionmode_is ("auto") |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4833 || ylabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4834 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4835 graphics_xform xform = get_transform (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4836 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4837 Matrix ext (1, 2, 0.0); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4838 ext = get_ticklabel_extents (get_ytick ().matrix_value (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4839 get_yticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4840 get_ylim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4841 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4842 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4843 ColumnVector p = |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4844 graphics_xform::xform_vector (xpTick, (ypTickN+ypTick)/2, zpTick); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4845 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4846 bool tick_along_z = nearhoriz || xisinf (fx); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4847 if (tick_along_z) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4848 p(2) += (signum(zpTick-zpTickN)*fz*ytickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4849 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4850 p(0) += (signum(xpTick-xpTickN)*fx*ytickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4851 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4852 p = xform.transform (p(0), p(1), p(2), false); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4853 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4854 switch (ystate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4855 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4856 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4857 p(0) += (!xyzSym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4858 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4859 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4860 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4861 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4862 p(0) += (y2Dright ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4863 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4864 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4865 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4866 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4867 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4868 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4869 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4870 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4871 if (ylabel_props.positionmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4872 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4873 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4874 ylabel_props.set_position (p.extract_n (0, 3).transpose ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4875 ylabel_props.set_positionmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4876 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4877 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4878 if (! is_empty && ylabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4879 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4880 ylabel_props.set_rotation (angle); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4881 ylabel_props.set_rotationmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4882 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4883 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4884 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4885 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4886 static bool updating_zlabel_position = false; |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4887 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4888 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4889 axes::properties::update_zlabel_position (void) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4890 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4891 if (updating_zlabel_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4892 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4893 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4894 text::properties& zlabel_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4895 (gh_manager::get_object (get_zlabel ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
4896 |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4897 bool camAuto = cameraupvectormode_is ("auto"); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
4898 bool is_empty = zlabel_props.get_string ().is_empty (); |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4899 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4900 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4901 frame.protect_var (updating_zlabel_position); |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4902 updating_zlabel_position = true; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4903 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4904 if (! is_empty) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4905 { |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4906 if (zlabel_props.horizontalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4907 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4908 zlabel_props.set_horizontalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4909 ((zstate > AXE_DEPTH_DIR || camAuto) ? "center" : "right"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4910 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4911 zlabel_props.set_horizontalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4912 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4913 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4914 if (zlabel_props.verticalalignmentmode_is ("auto")) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4915 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4916 zlabel_props.set_verticalalignment |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4917 (zstate == AXE_VERT_DIR |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4918 ? "bottom" : ((zSign || camAuto) ? "bottom" : "top")); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4919 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4920 zlabel_props.set_verticalalignmentmode ("auto"); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
4921 } |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4922 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4923 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4924 if (zlabel_props.positionmode_is ("auto") |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4925 || zlabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4926 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4927 graphics_xform xform = get_transform (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4928 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4929 Matrix ext (1, 2, 0.0); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4930 ext = get_ticklabel_extents (get_ztick ().matrix_value (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4931 get_zticklabel ().all_strings (), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4932 get_zlim ().matrix_value ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4933 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4934 double wmax = ext(0), hmax = ext(1), angle = 0; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4935 ColumnVector p; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4936 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4937 if (xySym) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4938 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4939 p = graphics_xform::xform_vector (xPlaneN, yPlane, |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4940 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4941 if (xisinf (fy)) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4942 p(0) += (signum(xPlaneN-xPlane)*fx*ztickoffset); |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4943 else |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4944 p(1) += (signum(yPlane-yPlaneN)*fy*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4945 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4946 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4947 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4948 p = graphics_xform::xform_vector (xPlane, yPlaneN, |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4949 (zpTickN+zpTick)/2); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4950 if (xisinf (fx)) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4951 p(1) += (signum(yPlaneN-yPlane)*fy*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4952 else |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4953 p(0) += (signum(xPlane-xPlaneN)*fx*ztickoffset); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4954 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4955 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4956 p = xform.transform (p(0), p(1), p(2), false); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4957 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4958 switch (zstate) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4959 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4960 case AXE_ANY_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4961 if (camAuto) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4962 { |
12348
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4963 p(0) -= wmax; |
d1e48a4a9a0b
Untabify and improve indentation
Konstantinos Poulios <logari81@googlemail.com>
parents:
12347
diff
changeset
|
4964 angle = 90; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4965 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4966 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4967 // FIXME -- what's the correct offset? |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4968 // |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4969 // p[0] += (!xySym ? wmax : -wmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4970 // p[1] += (zSign ? hmax : -hmax); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4971 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4972 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4973 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4974 case AXE_VERT_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4975 p(0) -= wmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4976 angle = 90; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4977 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4978 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4979 case AXE_HORZ_DIR: |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4980 p(1) += hmax; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4981 break; |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4982 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4983 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4984 if (zlabel_props.positionmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4985 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4986 p = xform.untransform (p(0), p(1), p(2), true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4987 zlabel_props.set_position (p.extract_n (0, 3).transpose ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4988 zlabel_props.set_positionmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4989 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4990 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4991 if (! is_empty && zlabel_props.rotationmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4992 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4993 zlabel_props.set_rotation (angle); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4994 zlabel_props.set_rotationmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4995 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
4996 } |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4997 } |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4998 |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
4999 static bool updating_title_position = false; |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5000 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5001 void |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5002 axes::properties::update_title_position (void) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5003 { |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5004 if (updating_title_position) |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5005 return; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5006 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5007 text::properties& title_props = reinterpret_cast<text::properties&> |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5008 (gh_manager::get_object (get_title ()).get_properties ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5009 |
12910
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5010 unwind_protect frame; |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5011 frame.protect_var (updating_title_position); |
e77284b6dac6
avoid possible infinite recursion in autopositioning of labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12777
diff
changeset
|
5012 updating_title_position = true; |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5013 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5014 if (title_props.positionmode_is ("auto")) |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5015 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5016 graphics_xform xform = get_transform (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5017 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5018 // FIXME: bbox should be stored in axes::properties |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5019 Matrix bbox = get_extent (false); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5020 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10), |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5021 (x_zlim(0)+x_zlim(1))/2, true); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5022 |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5023 title_props.set_position (p.extract_n(0, 3).transpose ()); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5024 title_props.set_positionmode ("auto"); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5025 } |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5026 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5027 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5028 void |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5029 axes::properties::update_autopos (const std::string& elem_type) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5030 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5031 if (elem_type == "xlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5032 update_xlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5033 else if (elem_type == "ylabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5034 update_ylabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5035 else if (elem_type == "zlabel") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5036 update_zlabel_position (); |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5037 else if (elem_type == "title") |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
5038 update_title_position (); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5039 else if (elem_type == "sync") |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5040 sync_positions (); |
12327
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5041 } |
2ad37783bf01
Move axes layout from opengl_renderer::draw_axes to axes::properties
Konstantinos Poulios <logari81@googlemail.com>
parents:
12221
diff
changeset
|
5042 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5043 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5044 normalized_aspectratios (Matrix& aspectratios, const Matrix& scalefactors, |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5045 double xlength, double ylength, double zlength) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5046 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5047 double xval = xlength/scalefactors(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5048 double yval = ylength/scalefactors(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5049 double zval = zlength/scalefactors(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5050 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5051 double minval = xmin (xmin (xval, yval), zval); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5052 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5053 aspectratios(0) = xval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5054 aspectratios(1) = yval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5055 aspectratios(2) = zval/minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5056 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5057 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5058 static void |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5059 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
|
5060 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
|
5061 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5062 if (tight) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5063 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5064 double minval = octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5065 double maxval = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5066 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5067 double max_neg = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5068 get_children_limits (minval, maxval, min_pos, max_neg, kids, limit_type); |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5069 if (!xisinf (minval) && !xisnan (minval) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5070 && !xisinf (maxval) && !xisnan (maxval)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5071 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5072 limits(0) = minval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5073 limits(1) = maxval; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5074 s = xmax(s, (maxval - minval) / (pbfactor * dafactor)); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5075 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5076 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5077 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5078 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
|
5079 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5080 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5081 static bool updating_aspectratios = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5082 |
7427 | 5083 void |
5084 axes::properties::update_aspectratios (void) | |
5085 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5086 if (updating_aspectratios) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5087 return; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5088 |
7526
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5089 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
|
5090 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
|
5091 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
|
5092 |
52d58b0463ed
graphics.cc, graphics.h.in: avoid some GCC warnings
John W. Eaton <jwe@octave.org>
parents:
7523
diff
changeset
|
5093 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
|
5094 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
|
5095 double dz = (zlimits(1)-zlimits(0)); |
7427 | 5096 |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5097 Matrix da = get_dataaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5098 Matrix pba = get_plotboxaspectratio ().matrix_value (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5099 |
7427 | 5100 if (dataaspectratiomode_is ("auto")) |
5101 { | |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5102 if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5103 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5104 pba = Matrix (1, 3, 1.0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5105 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5106 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5107 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5108 normalized_aspectratios (da, pba, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5109 dataaspectratio.set (da, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5110 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5111 else if (plotboxaspectratiomode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5112 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5113 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5114 plotboxaspectratio.set (pba, false); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5115 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5116 else |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5117 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5118 double s = -octave_Inf; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5119 bool modified_limits = false; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5120 Matrix kids; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5121 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5122 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
|
5123 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5124 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5125 kids = get_children (); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5126 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
|
5127 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
|
5128 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
|
5129 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5130 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
|
5131 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5132 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5133 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
|
5134 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5135 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
|
5136 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5137 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5138 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
|
5139 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5140 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
|
5141 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5142 modified_limits = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5143 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
|
5144 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5145 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5146 if (modified_limits) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5147 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5148 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5149 unwind_protect frame; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5150 frame.protect_var (updating_aspectratios); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5151 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5152 updating_aspectratios = true; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5153 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5154 dx = pba(0) *da(0); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5155 dy = pba(1) *da(1); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5156 dz = pba(2) *da(2); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5157 if (xisinf (s)) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5158 s = 1 / xmin (xmin (dx, dy), dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5159 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5160 if (xlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5161 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5162 dx = s * dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5163 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
|
5164 xlimits(1) = xlimits(0) + dx; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5165 set_xlim (xlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5166 set_xlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5167 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5168 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5169 if (ylimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5170 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5171 dy = s * dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5172 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
|
5173 ylimits(1) = ylimits(0) + dy; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5174 set_ylim (ylimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5175 set_ylimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5176 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5177 |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5178 if (zlimmode_is ("auto")) |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5179 { |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5180 dz = s * dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5181 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
|
5182 zlimits(1) = zlimits(0) + dz; |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5183 set_zlim (zlimits); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5184 set_zlimmode ("auto"); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5185 } |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5186 } |
7427 | 5187 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5188 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5189 normalized_aspectratios (pba, da, dx, dy, dz); |
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
5190 plotboxaspectratio.set (pba, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5191 } |
7427 | 5192 } |
5193 } | |
5194 | |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5195 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5196 axes::properties::update_font (void) |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5197 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5198 #ifdef HAVE_FREETYPE |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5199 #ifdef HAVE_FONTCONFIG |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5200 text_renderer.set_font (get ("fontname").string_value (), |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5201 get ("fontweight").string_value (), |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5202 get ("fontangle").string_value (), |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5203 get ("fontsize").double_value ()); |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5204 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5205 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5206 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5207 |
7447 | 5208 // The INTERNAL flag defines whether position or outerposition is used. |
5209 | |
7427 | 5210 Matrix |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5211 axes::properties::get_boundingbox (bool internal, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5212 const Matrix& parent_pix_size) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5213 { |
7447 | 5214 Matrix pos = (internal ? |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5215 get_position ().matrix_value () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5216 : get_outerposition ().matrix_value ()); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5217 Matrix parent_size (parent_pix_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5218 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5219 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5220 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5221 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5222 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5223 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5224 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5225 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5226 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5227 pos = convert_position (pos, get_units (), "pixels", parent_size); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
5228 |
7427 | 5229 pos(0)--; |
5230 pos(1)--; | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5231 pos(1) = parent_size(1) - pos(1) - pos(3); |
7427 | 5232 |
5233 return pos; | |
5234 } | |
5235 | |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5236 Matrix |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5237 axes::properties::get_extent (bool with_text, bool only_text_height) const |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5238 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5239 graphics_xform xform = get_transform (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5240 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5241 Matrix ext (1, 4, 0.0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5242 ext(0) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5243 ext(1) = octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5244 ext(2) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5245 ext(3) = -octave_Inf; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5246 for (int i = 0; i <= 1; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5247 for (int j = 0; j <= 1; j++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5248 for (int k = 0; k <= 1; k++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5249 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5250 ColumnVector p = xform.transform (i ? xPlaneN : xPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5251 j ? yPlaneN : yPlane, |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5252 k ? zPlaneN : zPlane, false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5253 ext(0) = std::min (ext(0), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5254 ext(1) = std::min (ext(1), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5255 ext(2) = std::max (ext(2), p(0)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5256 ext(3) = std::max (ext(3), p(1)); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5257 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5258 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5259 if (with_text) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5260 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5261 for (int i = 0; i < 4; i++) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5262 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5263 graphics_handle text_handle; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5264 if (i == 0) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5265 text_handle = get_title (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5266 else if (i == 1) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5267 text_handle = get_xlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5268 else if (i == 2) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5269 text_handle = get_ylabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5270 else if (i == 3) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5271 text_handle = get_zlabel (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5272 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5273 text::properties& text_props = reinterpret_cast<text::properties&> |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5274 (gh_manager::get_object (text_handle).get_properties ()); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5275 |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5276 Matrix text_pos = text_props.get_position ().matrix_value (); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5277 text_pos = xform.transform (text_pos(0), text_pos(1), text_pos(2)); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
5278 if (text_props.get_string ().is_empty ()) |
12502
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5279 { |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5280 ext(0) = std::min (ext(0), text_pos(0)); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5281 ext(1) = std::min (ext(1), text_pos(1)); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5282 ext(2) = std::max (ext(2), text_pos(0)); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5283 ext(3) = std::max (ext(3), text_pos(1)); |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5284 } |
13640f7f40bb
improve calculation of axes tightinset for empty axes labels/title
Konstantinos Poulios <logari81@googlemail.com>
parents:
12496
diff
changeset
|
5285 else |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5286 { |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5287 Matrix text_ext = text_props.get_extent_matrix (); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5288 |
12496
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5289 bool ignore_horizontal = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5290 bool ignore_vertical = false; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5291 if (only_text_height) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5292 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5293 double text_rotation = text_props.get_rotation(); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5294 if (text_rotation == 0. || text_rotation == 180.) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5295 ignore_horizontal = true; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5296 else if (text_rotation == 90. || text_rotation == 270.) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5297 ignore_vertical = true; |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5298 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5299 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5300 if (! ignore_horizontal) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5301 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5302 ext(0) = std::min (ext(0), text_pos(0)+text_ext(0)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5303 ext(2) = std::max (ext(2), text_pos(0)+text_ext(0)+text_ext(2)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5304 } |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5305 |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5306 if (! ignore_vertical) |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5307 { |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5308 ext(1) = std::min (ext(1), text_pos(1)-text_ext(1)-text_ext(3)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5309 ext(3) = std::max (ext(3), text_pos(1)-text_ext(1)); |
245b5efb07c2
fix axes position synchronization for long text objects
Konstantinos Poulios <logari81@gmail.com>
parents:
12483
diff
changeset
|
5310 } |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5311 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5312 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5313 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5314 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5315 ext(2) = ext(2)-ext(0); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5316 ext(3) = ext(3)-ext(1); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
5317 |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5318 return ext; |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5319 } |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5320 |
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
|
5321 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
|
5322 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
|
5323 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5324 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
|
5325 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5326 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
|
5327 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
|
5328 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5329 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
|
5330 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
|
5331 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5332 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5333 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5334 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5335 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
|
5336 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
|
5337 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5338 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
|
5339 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
|
5340 caseless_str new_units = get_units (); |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5341 position.set (octave_value (convert_position (get_position().matrix_value(), old_units, new_units, parent_bb)), false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5342 outerposition.set (octave_value (convert_position (get_outerposition().matrix_value(), old_units, new_units, parent_bb)), false); |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
5343 tightinset.set (octave_value (convert_position (get_tightinset().matrix_value(), old_units, new_units, parent_bb)), false); |
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
|
5344 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5345 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5346 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
|
5347 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
|
5348 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5349 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
|
5350 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5351 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
|
5352 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
|
5353 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5354 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
|
5355 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
|
5356 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5357 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5358 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5359 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5360 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
|
5361 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
|
5362 { |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5363 caseless_str new_units = get_fontunits (); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5364 double parent_height = get_boundingbox (true).elem (3); |
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
|
5365 double fsz = get_fontsize (); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5366 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5367 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
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
|
5368 |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5369 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
|
5370 } |
9d3a7ad94ee6
Respect the units and paperunits figure properties and the units and fontunits axes properties
David Bateman <dbateman@free.fr>
parents:
10990
diff
changeset
|
5371 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5372 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5373 axes::properties::get_fontsize_points (double box_pix_height) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5374 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5375 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5376 double parent_height = box_pix_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5377 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5378 if (fontunits_is ("normalized") && parent_height <= 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5379 parent_height = get_boundingbox (true).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5380 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5381 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5382 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
5383 |
7435 | 5384 ColumnVector |
5385 graphics_xform::xform_vector (double x, double y, double z) | |
7869 | 5386 { |
5387 return ::xform_vector (x, y, z); | |
5388 } | |
7435 | 5389 |
5390 Matrix | |
5391 graphics_xform::xform_eye (void) | |
7869 | 5392 { |
5393 return ::xform_matrix (); | |
5394 } | |
7435 | 5395 |
5396 ColumnVector | |
5397 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
|
5398 bool use_scale) const |
7435 | 5399 { |
5400 if (use_scale) | |
5401 { | |
5402 x = sx.scale (x); | |
5403 y = sy.scale (y); | |
5404 z = sz.scale (z); | |
5405 } | |
5406 | |
5407 return ::transform (xform, x, y, z); | |
5408 } | |
5409 | |
5410 ColumnVector | |
5411 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
|
5412 bool use_scale) const |
7435 | 5413 { |
5414 ColumnVector v = ::transform (xform_inv, x, y, z); | |
5415 | |
5416 if (use_scale) | |
5417 { | |
5418 v(0) = sx.unscale (v(0)); | |
5419 v(1) = sy.unscale (v(1)); | |
5420 v(2) = sz.unscale (v(2)); | |
5421 } | |
5422 | |
5423 return v; | |
5424 } | |
5425 | |
6836 | 5426 octave_value |
7189 | 5427 axes::get_default (const caseless_str& name) const |
6836 | 5428 { |
5429 octave_value retval = default_properties.lookup (name); | |
5430 | |
5431 if (retval.is_undefined ()) | |
5432 { | |
5433 graphics_handle parent = get_parent (); | |
5434 graphics_object parent_obj = gh_manager::get_object (parent); | |
5435 | |
5436 retval = parent_obj.get_default (name); | |
5437 } | |
5438 | |
5439 return retval; | |
5440 } | |
5441 | |
8333 | 5442 // FIXME -- remove. |
5443 // 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
|
5444 /* |
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
|
5445 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5446 check_limit_vals (double& min_val, double& max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5447 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5448 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
|
5449 { |
4fb2db9c87dd
Turn cdata properties into array_property. Add min/max computation to array_property.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7835
diff
changeset
|
5450 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
|
5451 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
|
5452 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
|
5453 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
|
5454 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
|
5455 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
|
5456 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
|
5457 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
|
5458 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5459 val = data.max_neg (); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5460 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5461 max_neg = val; |
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
|
5462 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5463 */ |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5464 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5465 static void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5466 check_limit_vals (double& min_val, double& max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5467 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5468 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
|
5469 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5470 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
|
5471 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5472 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
|
5473 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5474 if (! error_state && m.numel () == 4) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5475 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5476 double val; |
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 val = m(0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5479 if (! (xisinf (val) || xisnan (val)) && val < min_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5480 min_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5481 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5482 val = m(1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5483 if (! (xisinf (val) || xisnan (val)) && val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5484 max_val = val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5485 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5486 val = m(2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5487 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
|
5488 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5489 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5490 val = m(3); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5491 if (! (xisinf (val) || xisnan (val)) && val < 0 && val > max_neg) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5492 max_neg = val; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5493 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5494 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5495 } |
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
|
5496 |
12508
919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents:
12506
diff
changeset
|
5497 // magform(x) Returns (a, b), where x = a * 10^b, abs (a) >= 1., and b is |
919cadf334f8
Simplify calculation of number of tick labels. Bug #32692.
Marco Caliari <marco.caliari@univr.it>
parents:
12506
diff
changeset
|
5498 // integer. |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5499 |
7869 | 5500 static void |
5501 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
|
5502 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5503 if (x == 0) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5504 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5505 a = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5506 b = 0; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5507 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5508 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5509 { |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
5510 b = static_cast<int> (gnulib::floor (std::log10 (std::abs (x)))); |
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13132
diff
changeset
|
5511 a = x / std::pow (10.0, b); |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5512 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5513 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5514 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5515 // 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
|
5516 // 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
|
5517 // FIXME -- add log ticks |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5518 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5519 double |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5520 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
|
5521 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5522 int ticint = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5523 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5524 // 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
|
5525 // 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
|
5526 // 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
|
5527 // 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
|
5528 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5529 double a; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5530 int b, x; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5531 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5532 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
|
5533 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5534 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
|
5535 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
|
5536 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
|
5537 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5538 if (a < sqrt_2) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5539 x = 1; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5540 else if (a < sqrt_10) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5541 x = 2; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5542 else if (a < sqrt_50) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5543 x = 5; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5544 else |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5545 x = 10; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5546 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5547 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
|
5548 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5549 } |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5550 |
7222 | 5551 // Attempt to make "nice" limits from the actual max and min of the |
5552 // data. For log plots, we will also use the smallest strictly positive | |
5553 // value. | |
5554 | |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5555 Matrix |
7869 | 5556 axes::properties::get_axis_limits (double xmin, double xmax, |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5557 double min_pos, double max_neg, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5558 bool logscale) |
7222 | 5559 { |
5560 Matrix retval; | |
5561 | |
5562 double min_val = xmin; | |
5563 double max_val = xmax; | |
5564 | |
13757
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5565 if (xisinf (min_val) && min_val > 0 && xisinf (max_val) && max_val < 0) |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5566 { |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5567 retval = default_lim (logscale); |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5568 return retval; |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5569 } |
1e81e2e30af3
default limits for logscale plots
John W. Eaton <jwe@octave.org>
parents:
13756
diff
changeset
|
5570 else if (! (xisinf (min_val) || xisinf (max_val))) |
7222 | 5571 { |
5572 if (logscale) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5573 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5574 if (xisinf (min_pos) && xisinf (max_neg)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5575 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5576 // TODO -- max_neg is needed for "loglog ([0 -Inf])" |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5577 // This is the only place where max_neg is needed. |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5578 // Is there another way? |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5579 retval = default_lim (); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5580 retval(0) = pow (10., retval(0)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5581 retval(1) = pow (10., retval(1)); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5582 return retval; |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5583 } |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13736
diff
changeset
|
5584 if ((min_val <= 0 && max_val > 0)) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5585 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5586 warning ("axis: omitting nonpositive data in log plot"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5587 min_val = min_pos; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5588 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5589 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5590 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
|
5591 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5592 min_val *= 0.9; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5593 max_val *= 1.1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5594 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5595 if (min_val > 0) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5596 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5597 // Log plots with all positive data |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5598 min_val = pow (10, gnulib::floor (log10 (min_val))); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5599 max_val = pow (10, std::ceil (log10 (max_val))); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5600 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5601 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5602 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5603 // Log plots with all negative data |
13756
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13736
diff
changeset
|
5604 min_val = -pow (10, std::ceil (log10 (-min_val))); |
6dfebfa334cb
allow negative data log plots with OpenGL+FLTK graphics (bug #34232)
John W. Eaton <jwe@octave.org>
parents:
13736
diff
changeset
|
5605 max_val = -pow (10, gnulib::floor (log10 (-max_val))); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5606 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5607 } |
7222 | 5608 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5609 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5610 if (min_val == 0 && max_val == 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5611 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5612 min_val = -1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5613 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5614 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5615 // FIXME -- maybe this test should also be relative? |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5616 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
|
5617 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5618 min_val -= 0.1 * std::abs (min_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5619 max_val += 0.1 * std::abs (max_val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5620 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5621 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5622 double tick_sep = calc_tick_sep (min_val , max_val); |
12549
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5623 double min_tick = gnulib::floor (min_val / tick_sep); |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5624 double max_tick = std::ceil (max_val / tick_sep); |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5625 // Prevent round-off from cropping ticks |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5626 min_val = std::min (min_val, tick_sep * min_tick); |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5627 max_val = std::max (max_val, tick_sep * max_tick); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5628 } |
7222 | 5629 } |
5630 | |
5631 retval.resize (1, 2); | |
5632 | |
5633 retval(0) = min_val; | |
5634 retval(1) = max_val; | |
5635 | |
5636 return retval; | |
5637 } | |
5638 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5639 void |
7869 | 5640 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
|
5641 array_property& ticks, |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5642 array_property& mticks, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5643 bool limmode_is_auto, bool is_logscale) |
7446 | 5644 { |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5645 // FIXME -- add log ticks and lims |
7446 | 5646 |
5647 if (lims.get ().is_empty ()) | |
5648 return; | |
5649 | |
5650 double lo = (lims.get ().matrix_value ()) (0); | |
5651 double hi = (lims.get ().matrix_value ()) (1); | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5652 bool is_negative = lo < 0 && hi < 0; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5653 double tmp; |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5654 // FIXME should this be checked for somewhere else? (i.e. set{x,y,z}lim) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5655 if (hi < lo) |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5656 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5657 tmp = hi; |
7843
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5658 hi = lo; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5659 lo = tmp; |
d3dcfdfdc434
handle unsorted limits when calculatin gticks and limits
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7836
diff
changeset
|
5660 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5661 |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5662 if (is_logscale) |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5663 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5664 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5665 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5666 tmp = hi; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5667 hi = std::log10 (-lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5668 lo = std::log10 (-tmp); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5669 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5670 else |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5671 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5672 hi = std::log10 (hi); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5673 lo = std::log10 (lo); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5674 } |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5675 } |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5676 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5677 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
|
5678 |
13106
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5679 if (is_logscale && ! (xisinf (hi) || xisinf (lo))) |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5680 { |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5681 // FIXME - what if (hi-lo) < tick_sep? |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5682 // ex: loglog ([1 1.1]) |
13109
8e61aa0fac77
src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents:
13106
diff
changeset
|
5683 tick_sep = std::max (tick_sep, 1.); |
8e61aa0fac77
src/graphics.cc: Fix mistake in changeset c7512d0d52e8.
Ben Abbott <bpabbott@mac.com>
parents:
13106
diff
changeset
|
5684 tick_sep = std::ceil (tick_sep); |
13106
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5685 } |
c7512d0d52e8
src/graphics.cc: Ensure tick separation is in factors of 10 for log plots.
Ben Abbott <bpabbott@mac.com>
parents:
12587
diff
changeset
|
5686 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
5687 int i1 = static_cast<int> (gnulib::floor (lo / tick_sep)); |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5688 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
|
5689 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5690 if (limmode_is_auto) |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5691 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5692 // 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
|
5693 Matrix tmp_lims (1,2); |
12549
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5694 tmp_lims(0) = std::min (tick_sep * i1, lo); |
570193964185
graphics.cc: Prevent ticks from being cropped.
Ben Abbott <bpabbott@mac.com>
parents:
12508
diff
changeset
|
5695 tmp_lims(1) = std::max (tick_sep * i2, hi); |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5696 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5697 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5698 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5699 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
|
5700 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
|
5701 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
|
5702 tmp_lims(0) = std::pow (10., lo); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5703 if (is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5704 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5705 tmp = tmp_lims(0); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5706 tmp_lims(0) = -tmp_lims(1); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5707 tmp_lims(1) = -tmp; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5708 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5709 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5710 lims = tmp_lims; |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5711 } |
7446 | 5712 else |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5713 { |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5714 // 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
|
5715 i1 = static_cast<int> (std::ceil (lo / tick_sep)); |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
5716 i2 = static_cast<int> (gnulib::floor (hi / tick_sep)); |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5717 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5718 |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5719 Matrix tmp_ticks (1, i2-i1+1); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5720 for (int i = 0; i <= i2-i1; i++) |
7857
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5721 { |
09b1a9c88128
added (far from perfect) support for logscale ticks
Shai Ayal <shaiay@users.sourceforge.net>
parents:
7855
diff
changeset
|
5722 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
|
5723 if (is_logscale) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5724 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
|
5725 } |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5726 if (is_logscale && is_negative) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5727 { |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5728 Matrix rev_ticks (1, i2-i1+1); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5729 rev_ticks = -tmp_ticks; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5730 for (int i = 0; i <= i2-i1; i++) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5731 tmp_ticks (i) = rev_ticks (i2-i1-i); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5732 } |
7827
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5733 |
3584f37eac69
better tick and limit handling, still missing logscale support
Shai Ayal <shaiay@sourceforge.net>
parents:
7824
diff
changeset
|
5734 ticks = tmp_ticks; |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5735 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5736 int n = is_logscale ? 9 : 4; |
12157
0b9c1a7e350a
fix wrong dimensions of minor ticks vector
Konstantinos Poulios <logari81@googlemail.com>
parents:
12126
diff
changeset
|
5737 Matrix tmp_mticks (1, n * (tmp_ticks.numel () - 1)); |
12126
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5738 |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5739 for (int i = 0; i < tmp_ticks.numel ()-1; i++) |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5740 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5741 double d = (tmp_ticks (i+1) - tmp_ticks (i)) / (n+1); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5742 for (int j = 0; j < n; j++) |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5743 { |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5744 tmp_mticks (n*i+j) = tmp_ticks (i) + d * (j+1); |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5745 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5746 } |
85f9a5b211fd
restructuring draw_axes, enabling minor ticks/grid in fltk, closing bug 31800
Konstantinos Poulios <logari81@googlemail.com>
parents:
11598
diff
changeset
|
5747 mticks = tmp_mticks; |
7446 | 5748 } |
5749 | |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5750 void |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5751 axes::properties::calc_ticklabels (const array_property& ticks, |
13211
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5752 any_property& labels, bool logscale) |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5753 { |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5754 Matrix values = ticks.get ().matrix_value (); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5755 Cell c (values.dims ()); |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5756 std::ostringstream os; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5757 |
13211
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5758 if (logscale) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5759 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5760 double significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5761 double exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5762 double exp_max = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5763 double exp_min = 0.; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5764 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5765 for (int i = 0; i < values.numel (); i++) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5766 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5767 exp_max = std::max (exp_max, std::log10 (values(i))); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5768 exp_min = std::max (exp_min, std::log10 (values(i))); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5769 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5770 |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5771 for (int i = 0; i < values.numel (); i++) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5772 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5773 if (values(i) < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5774 exponent = gnulib::floor (std::log10 (-values(i))); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5775 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5776 exponent = gnulib::floor (std::log10 (values(i))); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5777 significand = values(i) * std::pow (10., -exponent); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5778 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5779 os << significand; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5780 if (exponent < 0.) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5781 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5782 os << "e-"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5783 exponent = -exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5784 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5785 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5786 os << "e+"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5787 if (exponent < 10. && (exp_max > 9 || exp_min < -9)) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5788 os << "0"; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5789 os << exponent; |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5790 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5791 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5792 } |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5793 else |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5794 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5795 for (int i = 0; i < values.numel (); i++) |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5796 { |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5797 os.str (std::string ()); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5798 os << values(i); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5799 c(i) = os.str (); |
78744376463a
src/graphics.cc: Consistent log-scale axis tick labels.
Ben Abbott <bpabbott@mac.com>
parents:
13210
diff
changeset
|
5800 } |
9347
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5801 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5802 |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5803 labels = c; |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5804 } |
3da821b161e9
imported patch ticklabel
Michael Goffioul <michael.goffioul@gmail.com>
parents:
9316
diff
changeset
|
5805 |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5806 Matrix |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5807 axes::properties::get_ticklabel_extents (const Matrix& ticks, |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5808 const string_vector& ticklabels, |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5809 const Matrix& limits) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5810 { |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
5811 #ifndef HAVE_FREETYPE |
12334
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5812 double fontsize = get ("fontsize").double_value (); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5813 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5814 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5815 Matrix ext (1, 2, 0.0); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5816 double wmax = 0., hmax = 0.; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5817 int n = std::min (ticklabels.numel (), ticks.numel ()); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5818 for (int i = 0; i < n; i++) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5819 { |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5820 double val = ticks(i); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5821 if (limits(0) <= val && val <= limits(1)) |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5822 { |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5823 #ifdef HAVE_FREETYPE |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5824 ext = text_renderer.get_extent (ticklabels(i)); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5825 wmax = std::max (wmax, ext(0)); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5826 hmax = std::max (hmax, ext(1)); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5827 #else |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5828 //FIXME: find a better approximation |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5829 int len = ticklabels(i).length(); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5830 wmax = std::max (wmax, 0.5*fontsize*len); |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5831 hmax = fontsize; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5832 #endif |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5833 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5834 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5835 |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5836 ext(0) = wmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5837 ext(1) = hmax; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5838 return ext; |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5839 } |
63dc132a1000
Move axes labels and title positioning to axes::properties
Konstantinos Poulios <logari81@gmail.com>
parents:
12327
diff
changeset
|
5840 |
9455 | 5841 void |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5842 get_children_limits (double& min_val, double& max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5843 double& min_pos, double& max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5844 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
|
5845 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5846 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
|
5847 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5848 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
|
5849 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5850 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
|
5851 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
|
5852 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5853 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
|
5854 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5855 if (obj.is_xliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5856 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5857 octave_value lim = obj.get_xlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5858 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5859 check_limit_vals (min_val, max_val, min_pos, max_neg, lim); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5860 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5861 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5862 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5863 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5864 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
|
5865 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
|
5866 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5867 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
|
5868 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5869 if (obj.is_yliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5870 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5871 octave_value lim = obj.get_ylim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5872 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5873 check_limit_vals (min_val, max_val, min_pos, max_neg, lim); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5874 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5875 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5876 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5877 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5878 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
|
5879 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
|
5880 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5881 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
|
5882 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5883 if (obj.is_zliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5884 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5885 octave_value lim = obj.get_zlim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5886 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5887 check_limit_vals (min_val, max_val, min_pos, max_neg, lim); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5888 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5889 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5890 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5891 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5892 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
|
5893 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
|
5894 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5895 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
|
5896 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5897 if (obj.is_climinclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5898 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5899 octave_value lim = obj.get_clim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5900 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5901 check_limit_vals (min_val, max_val, min_pos, max_neg, lim); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5902 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5903 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5904 break; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5905 |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5906 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
|
5907 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
|
5908 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5909 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
|
5910 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5911 if (obj.is_aliminclude ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5912 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5913 octave_value lim = obj.get_alim (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5914 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5915 check_limit_vals (min_val, max_val, min_pos, max_neg, lim); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5916 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
5917 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5918 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5919 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5920 default: |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5921 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5922 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5923 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
5924 |
7222 | 5925 static bool updating_axis_limits = false; |
5926 | |
7214 | 5927 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5928 axes::update_axis_limits (const std::string& axis_type, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5929 const graphics_handle& h) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5930 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5931 if (updating_axis_limits) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5932 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5933 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5934 Matrix kids = Matrix (1, 1, h.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
5935 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5936 double min_val = octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5937 double max_val = -octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5938 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5939 double max_neg = -octave_Inf; |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5940 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5941 char update_type = 0; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5942 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5943 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5944 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5945 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5946 #define FIX_LIMITS \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5947 if (limits.numel() == 4) \ |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5948 { \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5949 val = limits(0); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5950 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5951 min_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5952 val = limits(1); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5953 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5954 max_val = val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5955 val = limits(2); \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5956 if (! (xisinf (val) || xisnan (val))) \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5957 min_pos = val; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5958 val = limits(3); \ |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5959 if (! (xisinf (val) || xisnan (val))) \ |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5960 max_neg = val; \ |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5961 } \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5962 else \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5963 { \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5964 limits.resize(4, 1); \ |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5965 limits(0) = min_val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5966 limits(1) = max_val; \ |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5967 limits(2) = min_pos; \ |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5968 limits(3) = max_neg; \ |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5969 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5970 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5971 if (axis_type == "xdata" || axis_type == "xscale" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5972 || axis_type == "xlimmode" || axis_type == "xliminclude" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5973 || axis_type == "xlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5974 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5975 if (xproperties.xlimmode_is ("auto")) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5976 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5977 limits = xproperties.get_xlim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5978 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5979 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5980 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5981 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5982 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5983 min_pos, max_neg, |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5984 xproperties.xscale_is ("log")); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5985 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5986 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5987 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5988 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5989 else if (axis_type == "ydata" || axis_type == "yscale" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5990 || axis_type == "ylimmode" || axis_type == "yliminclude" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5991 || axis_type == "ylim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5992 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5993 if (xproperties.ylimmode_is ("auto")) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5994 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5995 limits = xproperties.get_ylim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5996 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
5997 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5998 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
5999 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6000 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6001 min_pos, max_neg, |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6002 xproperties.yscale_is ("log")); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6003 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6004 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6005 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6006 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6007 else if (axis_type == "zdata" || axis_type == "zscale" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6008 || axis_type == "zlimmode" || axis_type == "zliminclude" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6009 || axis_type == "zlim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6010 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6011 if (xproperties.zlimmode_is ("auto")) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6012 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6013 limits = xproperties.get_zlim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6014 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6015 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6016 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6017 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6018 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6019 min_pos, max_neg, |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6020 xproperties.zscale_is ("log")); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6021 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6022 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6023 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6024 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6025 else if (axis_type == "cdata" || axis_type == "climmode" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6026 || axis_type == "cdatamapping" || axis_type == "climinclude" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6027 || axis_type == "clim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6028 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6029 if (xproperties.climmode_is ("auto")) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6030 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6031 limits = xproperties.get_clim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6032 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6033 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6034 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c'); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6035 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6036 if (min_val > max_val) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6037 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6038 min_val = min_pos = 0; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6039 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6040 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6041 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6042 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6043 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6044 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6045 } |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6046 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6047 limits.resize (1, 2); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6048 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6049 limits(0) = min_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6050 limits(1) = max_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6051 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6052 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6053 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6054 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6055 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6056 else if (axis_type == "alphadata" || axis_type == "alimmode" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6057 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6058 || axis_type == "alim") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6059 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6060 if (xproperties.alimmode_is ("auto")) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6061 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6062 limits = xproperties.get_alim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6063 FIX_LIMITS ; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6064 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6065 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a'); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6066 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6067 if (min_val > max_val) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6068 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6069 min_val = min_pos = 0; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6070 max_val = 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6071 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6072 else if (min_val == max_val) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6073 max_val = min_val + 1; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6074 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6075 limits.resize (1, 2); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6076 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6077 limits(0) = min_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6078 limits(1) = max_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6079 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6080 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6081 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6082 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6083 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6084 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6085 #undef FIX_LIMITS |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6086 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6087 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6088 frame.protect_var (updating_axis_limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6089 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6090 updating_axis_limits = true; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6091 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6092 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6093 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6094 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6095 xproperties.set_xlim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6096 xproperties.set_xlimmode ("auto"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6097 xproperties.update_xlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6098 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6099 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6100 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6101 xproperties.set_ylim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6102 xproperties.set_ylimmode ("auto"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6103 xproperties.update_ylim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6104 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6105 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6106 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6107 xproperties.set_zlim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6108 xproperties.set_zlimmode ("auto"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6109 xproperties.update_zlim (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6110 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6111 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6112 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6113 xproperties.set_clim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6114 xproperties.set_climmode ("auto"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6115 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6116 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6117 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6118 xproperties.set_alim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6119 xproperties.set_alimmode ("auto"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6120 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6121 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6122 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6123 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6124 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6125 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6126 xproperties.update_transform (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6127 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6128 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6129 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6130 void |
7222 | 6131 axes::update_axis_limits (const std::string& axis_type) |
7214 | 6132 { |
11167
51ac3a08e53c
Fix {d,pb}aspectratios for OpenGL backends.
Konstantinos Poulios <logari81@googlemail.com>
parents:
11163
diff
changeset
|
6133 if (updating_axis_limits || updating_aspectratios) |
7222 | 6134 return; |
6135 | |
6136 Matrix kids = xproperties.get_children (); | |
6137 | |
6138 double min_val = octave_Inf; | |
6139 double max_val = -octave_Inf; | |
6140 double min_pos = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6141 double max_neg = -octave_Inf; |
7222 | 6142 |
6143 char update_type = 0; | |
6144 | |
6145 Matrix limits; | |
6146 | |
6147 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
|
6148 || 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
|
6149 || axis_type == "xlim") |
7222 | 6150 { |
7363 | 6151 if (xproperties.xlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6152 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6153 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6154 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6155 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6156 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6157 xproperties.xscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6158 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6159 update_type = 'x'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6160 } |
7222 | 6161 } |
6162 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
|
6163 || axis_type == "ylimmode" || axis_type == "yliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6164 || axis_type == "ylim") |
7222 | 6165 { |
7363 | 6166 if (xproperties.ylimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6167 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6168 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6169 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6170 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6171 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6172 xproperties.yscale_is ("log")); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6173 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6174 update_type = 'y'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6175 } |
7222 | 6176 } |
6177 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
|
6178 || axis_type == "zlimmode" || axis_type == "zliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6179 || axis_type == "zlim") |
7222 | 6180 { |
7363 | 6181 if (xproperties.zlimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6182 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6183 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z'); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6184 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6185 limits = xproperties.get_axis_limits (min_val, max_val, |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6186 min_pos, max_neg, |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6187 xproperties.zscale_is ("log")); |
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 update_type = 'z'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6190 } |
7222 | 6191 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6192 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
|
6193 || axis_type == "cdatamapping" || axis_type == "climinclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6194 || axis_type == "clim") |
7222 | 6195 { |
7363 | 6196 if (xproperties.climmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6197 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6198 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c'); |
10315
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 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6201 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6202 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6203 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6204 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6205 else if (min_val == max_val) |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6206 { |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6207 max_val = min_val + 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6208 min_val -= 1; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13236
diff
changeset
|
6209 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6210 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6211 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6212 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6213 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6214 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6215 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6216 update_type = 'c'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6217 } |
7222 | 6218 |
6219 } | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6220 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
|
6221 || axis_type == "alphadatamapping" || axis_type == "aliminclude" |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6222 || 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
|
6223 { |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6224 if (xproperties.alimmode_is ("auto")) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6225 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6226 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a'); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6227 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6228 if (min_val > max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6229 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6230 min_val = min_pos = 0; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6231 max_val = 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6232 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6233 else if (min_val == max_val) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6234 max_val = min_val + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6235 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6236 limits.resize (1, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6237 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6238 limits(0) = min_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6239 limits(1) = max_val; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6240 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6241 update_type = 'a'; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6242 } |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6243 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6244 } |
7222 | 6245 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6246 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6247 frame.protect_var (updating_axis_limits); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
6248 |
7222 | 6249 updating_axis_limits = true; |
6250 | |
6251 switch (update_type) | |
6252 { | |
6253 case 'x': | |
6254 xproperties.set_xlim (limits); | |
6255 xproperties.set_xlimmode ("auto"); | |
7446 | 6256 xproperties.update_xlim (); |
7222 | 6257 break; |
6258 | |
6259 case 'y': | |
6260 xproperties.set_ylim (limits); | |
6261 xproperties.set_ylimmode ("auto"); | |
7446 | 6262 xproperties.update_ylim (); |
7222 | 6263 break; |
6264 | |
6265 case 'z': | |
6266 xproperties.set_zlim (limits); | |
6267 xproperties.set_zlimmode ("auto"); | |
7446 | 6268 xproperties.update_zlim (); |
7222 | 6269 break; |
6270 | |
6271 case 'c': | |
6272 xproperties.set_clim (limits); | |
6273 xproperties.set_climmode ("auto"); | |
6274 break; | |
6275 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6276 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
|
6277 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
|
6278 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
|
6279 break; |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6280 |
7222 | 6281 default: |
6282 break; | |
6283 } | |
6284 | |
7427 | 6285 xproperties.update_transform (); |
7214 | 6286 } |
6287 | |
9455 | 6288 inline |
6289 double force_in_range (const double x, const double lower, const double upper) | |
6290 { | |
6291 if (x < lower) | |
6292 { return lower; } | |
6293 else if (x > upper) | |
6294 { return upper; } | |
6295 else | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6296 { return x; } |
9455 | 6297 } |
6298 | |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6299 void |
9455 | 6300 axes::properties::zoom_about_point (double x, double y, double factor, |
6301 bool push_to_zoom_stack) | |
6302 { | |
6303 // FIXME: Do we need error checking here? | |
6304 Matrix xlims = get_xlim ().matrix_value (); | |
6305 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6306 |
9455 | 6307 // Get children axes limits |
6308 Matrix kids = get_children (); | |
6309 double minx = octave_Inf; | |
6310 double maxx = -octave_Inf; | |
6311 double min_pos_x = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6312 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6313 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x'); |
9455 | 6314 |
6315 double miny = octave_Inf; | |
6316 double maxy = -octave_Inf; | |
6317 double min_pos_y = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6318 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6319 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6320 |
9455 | 6321 // Perform the zooming |
6322 xlims (0) = x + factor * (xlims (0) - x); | |
6323 xlims (1) = x + factor * (xlims (1) - x); | |
6324 ylims (0) = y + factor * (ylims (0) - y); | |
6325 ylims (1) = y + factor * (ylims (1) - y); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6326 |
9455 | 6327 zoom (xlims, ylims, push_to_zoom_stack); |
6328 } | |
6329 | |
6330 void | |
6331 axes::properties::zoom (const Matrix& xl, const Matrix& yl, bool push_to_zoom_stack) | |
6332 { | |
6333 if (push_to_zoom_stack) | |
6334 { | |
6335 zoom_stack.push_front (xlimmode.get ()); | |
6336 zoom_stack.push_front (xlim.get ()); | |
6337 zoom_stack.push_front (ylimmode.get ()); | |
6338 zoom_stack.push_front (ylim.get ()); | |
6339 } | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6340 |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6341 xlim = xl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6342 xlimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6343 ylim = yl; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6344 ylimmode = "manual"; |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6345 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6346 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6347 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6348 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6349 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6350 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6351 void |
9455 | 6352 axes::properties::translate_view (double delta_x, double delta_y) |
6353 { | |
6354 // FIXME: Do we need error checking here? | |
6355 Matrix xlims = get_xlim ().matrix_value (); | |
6356 Matrix ylims = get_ylim ().matrix_value (); | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6357 |
9455 | 6358 // Get children axes limits |
6359 Matrix kids = get_children (); | |
6360 double minx = octave_Inf; | |
6361 double maxx = -octave_Inf; | |
6362 double min_pos_x = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6363 double max_neg_x = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6364 get_children_limits (minx, maxx, min_pos_x, max_neg_x, kids, 'x'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6365 |
9455 | 6366 double miny = octave_Inf; |
6367 double maxy = -octave_Inf; | |
6368 double min_pos_y = octave_Inf; | |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6369 double max_neg_y = -octave_Inf; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6370 get_children_limits (miny, maxy, min_pos_y, max_neg_y, kids, 'y'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6371 |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6372 xlims (0) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6373 xlims (1) += delta_x; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6374 ylims (0) += delta_y; |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6375 ylims (1) += delta_y; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6376 |
9455 | 6377 zoom (xlims, ylims, false); |
6378 } | |
6379 | |
6380 void | |
10792
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6381 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
|
6382 { |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6383 Matrix v = get_view ().matrix_value (); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6384 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6385 v (1) += delta_el; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6386 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6387 if(v(1) > 90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6388 v(1) = 90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6389 if(v(1) < -90) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6390 v(1) = -90; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6391 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
6392 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
|
6393 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6394 set_view(v); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6395 update_transform(); |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6396 } |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6397 |
91342260063e
mouse rotation for fltk backend
Shai Ayal <shaiay@users.sourceforge.net>
parents:
10733
diff
changeset
|
6398 void |
7855
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6399 axes::properties::unzoom (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6400 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6401 if (zoom_stack.size () >= 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6402 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6403 ylim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6404 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6405 ylimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6406 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6407 xlim = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6408 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6409 xlimmode = zoom_stack.front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6410 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6411 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6412 update_transform (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6413 update_xlim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6414 update_ylim (false); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6415 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6416 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6417 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6418 void |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6419 axes::properties::clear_zoom_stack (void) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6420 { |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6421 while (zoom_stack.size () > 4) |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6422 zoom_stack.pop_front (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6423 |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6424 unzoom (); |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6425 } |
f317f14516cb
Add zoom stack facility in axes object.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7849
diff
changeset
|
6426 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6427 void |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6428 axes::reset_default_properties (void) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6429 { |
10733
f72a761a784c
eliminate code duplication in reset_default_properties methods
John W. Eaton <jwe@octave.org>
parents:
10722
diff
changeset
|
6430 ::reset_default_properties (default_properties); |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6431 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
6432 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6433 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6434 axes::initialize (const graphics_object& go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6435 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6436 base_graphics_object::initialize (go); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6437 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6438 xinitialize (xproperties.get_title ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6439 xinitialize (xproperties.get_xlabel ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6440 xinitialize (xproperties.get_ylabel ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6441 xinitialize (xproperties.get_zlabel ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6442 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6443 |
7363 | 6444 // --------------------------------------------------------------------- |
6445 | |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6446 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6447 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
|
6448 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6449 Matrix m (1, 4); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6450 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6451 m(0) = xdata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6452 m(1) = xdata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6453 m(2) = xdata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6454 m(3) = xdata.max_neg (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6455 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6456 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
|
6457 } |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6458 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6459 Matrix |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6460 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
|
6461 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6462 Matrix m (1, 4); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6463 |
10596
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6464 m(0) = ydata.min_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6465 m(1) = ydata.max_val (); |
24e915c602e7
Remove line object props ldata, udata, xldata, xudata.
Ben Abbott <bpabbott@mac.com>
parents:
10565
diff
changeset
|
6466 m(2) = ydata.min_pos (); |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6467 m(3) = ydata.max_neg (); |
7862
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6468 |
8f3459a90bf3
Redesign axis limit computation handling (using hidden limit properties in child objects)
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7860
diff
changeset
|
6469 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
|
6470 } |
6406 | 6471 |
6472 // --------------------------------------------------------------------- | |
6473 | |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6474 Matrix |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6475 text::properties::get_data_position (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6476 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6477 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6478 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6479 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6480 pos = convert_text_position (pos, *this, get_units (), "data"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6481 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6482 return pos; |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6483 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6484 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6485 Matrix |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6486 text::properties::get_extent_matrix (void) const |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6487 { |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6488 return extent.get ().matrix_value (); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6489 } |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6490 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6491 octave_value |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6492 text::properties::get_extent (void) const |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6493 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6494 Matrix m = extent.get ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6495 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6496 return convert_text_position (m, *this, "pixels", get_units ()); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6497 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6498 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6499 void |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6500 text::properties::update_font (void) |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6501 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6502 #ifdef HAVE_FREETYPE |
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
|
6503 #ifdef HAVE_FONTCONFIG |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6504 renderer.set_font (get ("fontname").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6505 get ("fontweight").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6506 get ("fontangle").string_value (), |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6507 get ("fontsize").double_value ()); |
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
|
6508 #endif |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6509 renderer.set_color (get_color_rgb ()); |
12777
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6510 #endif |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6511 } |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6512 |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6513 void |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6514 text::properties::update_text_extent (void) |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6515 { |
6c1d0f03c331
Avoid redundant calls to set_font of text renderers (Bug #31305)
Konstantinos Poulios <logari81@gmail.com>
parents:
12685
diff
changeset
|
6516 #ifdef HAVE_FREETYPE |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6517 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6518 int halign = 0, valign = 0; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6519 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6520 if (horizontalalignment_is ("center")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6521 halign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6522 else if (horizontalalignment_is ("right")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6523 halign = 2; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6524 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6525 if (verticalalignment_is ("top")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6526 valign = 2; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6527 else if (verticalalignment_is ("baseline")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6528 valign = 3; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6529 else if (verticalalignment_is ("middle")) |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6530 valign = 1; |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6531 |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6532 Matrix bbox; |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6533 |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6534 // FIXME: string should be parsed only when modified, for efficiency |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6535 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6536 octave_value string_prop = get_string (); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6537 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6538 string_vector sv = string_prop.all_strings (); |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6539 |
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6540 renderer.text_to_pixels (sv.join ("\n"), pixels, bbox, |
11455
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6541 halign, valign, get_rotation ()); |
2be9e22796d2
improvements in text-extent calculation
Konstantinos Poulios <logari81@googlemail.com>
parents:
11450
diff
changeset
|
6542 set_extent (bbox); |
12965
22bc9ec80c2c
allow multi-line string property for text objects using cell arrays or char matrices
Ben Abbott <bpabbott@mac.com>
parents:
12910
diff
changeset
|
6543 |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6544 #endif |
12440
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6545 |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6546 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") || |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6547 autopos_tag_is ("zlabel") || autopos_tag_is ("title")) |
2ed62b9f949e
synchronization of axes position and outerposition
Konstantinos Poulios <logari81@googlemail.com>
parents:
12422
diff
changeset
|
6548 update_autopos ("sync"); |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6549 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6550 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6551 void |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6552 text::properties::request_autopos (void) |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6553 { |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6554 if (autopos_tag_is ("xlabel") || autopos_tag_is ("ylabel") || |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6555 autopos_tag_is ("zlabel") || autopos_tag_is ("title")) |
12422
a3be83af8cfa
simplifications in position updating functions for axes labels and titles
Konstantinos Poulios <logari81@gmail.com>
parents:
12389
diff
changeset
|
6556 update_autopos (get_autopos_tag ()); |
12389
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6557 } |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6558 |
5367bd36b9f8
implement autopositioning requests from text objects to axes
Konstantinos Poulios <logari81@googlemail.com>
parents:
12348
diff
changeset
|
6559 void |
10402
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6560 text::properties::update_units (void) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6561 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6562 if (! units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6563 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6564 set_xliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6565 set_yliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6566 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6567 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6568 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6569 Matrix pos = get_position ().matrix_value (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6570 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6571 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
|
6572 // 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
|
6573 // 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
|
6574 // to "off". |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6575 set_position (pos); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6576 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6577 if (units_is ("data")) |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6578 { |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6579 set_xliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6580 set_yliminclude ("on"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6581 // FIXME: see above |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6582 set_zliminclude ("off"); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6583 } |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6584 |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6585 cached_units = get_units (); |
9f2bf537a651
Implement text extent property
Michael Goffioul <michael.goffioul@gmail.com>
parents:
10315
diff
changeset
|
6586 } |
6406 | 6587 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6588 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6589 text::properties::get_fontsize_points (double box_pix_height) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6590 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6591 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6592 double parent_height = box_pix_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6593 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6594 if (fontunits_is ("normalized") && parent_height <= 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6595 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6596 graphics_object go (gh_manager::get_object (get___myhandle__ ())); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6597 graphics_object ax (go.get_ancestor ("axes")); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6598 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6599 parent_height = ax.get_properties ().get_boundingbox (true).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6600 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6601 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6602 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6603 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6604 |
6406 | 6605 // --------------------------------------------------------------------- |
6606 | |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6607 octave_value |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6608 image::properties::get_color_data (void) const |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6609 { |
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6610 return convert_cdata (*this, get_cdata (), |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6611 cdatamapping_is ("scaled"), 3); |
9680
73153525df9a
initial implementation of OpenGL image rendering
Shai Ayal <shaiay@users.sourceforge.net>
parents:
9605
diff
changeset
|
6612 } |
6406 | 6613 |
6614 // --------------------------------------------------------------------- | |
6615 | |
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
|
6616 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
|
6617 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
|
6618 { |
11168
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6619 octave_value fvc = get_facevertexcdata(); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6620 if (fvc.is_undefined () || fvc.is_empty ()) |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6621 return Matrix (); |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6622 else |
36442102c340
Fix treatment of facevertexcdata if facecolor is 'none' with the fltk backend
David Bateman <dbateman@free.fr>
parents:
11167
diff
changeset
|
6623 return convert_cdata (*this, fvc,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
|
6624 } |
6807 | 6625 |
6626 // --------------------------------------------------------------------- | |
6627 | |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6628 octave_value |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6629 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
|
6630 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6631 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
|
6632 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6633 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6634 inline void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6635 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
|
6636 double x2, double y2, double z2, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6637 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
|
6638 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6639 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
|
6640 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
|
6641 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
|
6642 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6643 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6644 void |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6645 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
|
6646 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6647 if (normalmode_is ("auto")) |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6648 { |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6649 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
|
6650 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
|
6651 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
|
6652 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6653 |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6654 int p = z.columns (), q = z.rows (); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6655 int i1 = 0, i2 = 0, i3 = 0; |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6656 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
|
6657 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6658 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
|
6659 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
|
6660 |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6661 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
|
6662 |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6663 for (int i = 0; i < p; i++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6664 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6665 if (y_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6666 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6667 i1 = i - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6668 i2 = i; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6669 i3 = i + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6670 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6671 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6672 for (int j = 0; j < q; j++) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6673 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6674 if (x_mat) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6675 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6676 j1 = j - 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6677 j2 = j; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6678 j3 = j + 1; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6679 } |
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 double& nx = n(j, i, 0); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6682 double& ny = n(j, i, 1); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6683 double& nz = n(j, i, 2); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6684 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6685 if ((j > 0) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6686 // upper left quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6687 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
|
6688 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
|
6689 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6690 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6691 if ((j > 0) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6692 // upper right quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6693 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
|
6694 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
|
6695 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6696 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6697 if ((j < (q - 1)) && (i > 0)) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6698 // lower left quadrangle |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6699 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
|
6700 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
|
6701 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6702 |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6703 if ((j < (q - 1)) && (i < (p -1))) |
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6704 // lower right quadrangle |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6705 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
|
6706 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
|
6707 nx, ny, nz); |
8449
448188853722
Calculate surface normals for boundaries, use more neighboring
Kai Habel
parents:
8341
diff
changeset
|
6708 |
11450
5eb10763069f
substitute and use LAPACK_LIBS in mkoctfile script
John W. Eaton <jwe@octave.org>
parents:
11431
diff
changeset
|
6709 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
|
6710 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6711 nx /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6712 ny /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6713 nz /= d; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6714 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
6715 } |
7829
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6716 vertexnormals = n; |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6717 } |
8ca8e97e8c0a
Add rendering interface for surface object (no implementation yet).
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7828
diff
changeset
|
6718 } |
6406 | 6719 |
6720 // --------------------------------------------------------------------- | |
6721 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6722 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6723 hggroup::properties::update_limits (void) const |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6724 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6725 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6726 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6727 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6728 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6729 obj.update_axis_limits ("xlim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6730 obj.update_axis_limits ("ylim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6731 obj.update_axis_limits ("zlim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6732 obj.update_axis_limits ("clim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6733 obj.update_axis_limits ("alim"); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6734 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6735 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6736 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6737 void |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6738 hggroup::properties::update_limits (const graphics_handle& h) const |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6739 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6740 graphics_object obj = gh_manager::get_object (__myhandle__); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6741 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6742 if (obj) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6743 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6744 obj.update_axis_limits ("xlim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6745 obj.update_axis_limits ("ylim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6746 obj.update_axis_limits ("zlim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6747 obj.update_axis_limits ("clim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6748 obj.update_axis_limits ("alim", h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6749 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6750 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6751 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6752 static bool updating_hggroup_limits = false; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6753 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6754 void |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6755 hggroup::update_axis_limits (const std::string& axis_type, |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6756 const graphics_handle& h) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6757 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6758 if (updating_hggroup_limits) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6759 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6760 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6761 Matrix kids = Matrix (1, 1, h.value ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6762 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6763 double min_val = octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6764 double max_val = -octave_Inf; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6765 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6766 double max_neg = -octave_Inf; |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6767 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6768 Matrix limits; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6769 double val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6770 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6771 char update_type = 0; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6772 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6773 if (axis_type == "xlim" || axis_type == "xliminclude") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6774 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6775 limits = xproperties.get_xlim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6776 update_type = 'x'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6777 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6778 else if (axis_type == "ylim" || axis_type == "yliminclude") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6779 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6780 limits = xproperties.get_ylim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6781 update_type = 'y'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6782 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6783 else if (axis_type == "zlim" || axis_type == "zliminclude") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6784 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6785 limits = xproperties.get_zlim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6786 update_type = 'z'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6787 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6788 else if (axis_type == "clim" || axis_type == "climinclude") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6789 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6790 limits = xproperties.get_clim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6791 update_type = 'c'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6792 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6793 else if (axis_type == "alim" || axis_type == "aliminclude") |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6794 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6795 limits = xproperties.get_alim ().matrix_value (); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6796 update_type = 'a'; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6797 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6798 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6799 if (limits.numel() == 4) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6800 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6801 val = limits(0); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6802 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6803 min_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6804 val = limits(1); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6805 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6806 max_val = val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6807 val = limits(2); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6808 if (! (xisinf (val) || xisnan (val))) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6809 min_pos = val; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6810 val = limits(3); |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6811 if (! (xisinf (val) || xisnan (val))) |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6812 max_neg = val; |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6813 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6814 else |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6815 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6816 limits.resize(4,1); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6817 limits(0) = min_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6818 limits(1) = max_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6819 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6820 limits(3) = max_neg; |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6821 } |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6822 |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6823 get_children_limits (min_val, max_val, min_pos, max_neg, kids, update_type); |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6824 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6825 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6826 frame.protect_var (updating_hggroup_limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6827 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6828 updating_hggroup_limits = true; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6829 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6830 if (limits(0) != min_val || limits(1) != max_val |
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6831 || limits(2) != min_pos || limits(3) != max_neg) |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6832 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6833 limits(0) = min_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6834 limits(1) = max_val; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6835 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6836 limits(3) = max_neg; |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6837 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6838 switch (update_type) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6839 { |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6840 case 'x': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6841 xproperties.set_xlim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6842 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6843 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6844 case 'y': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6845 xproperties.set_ylim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6846 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6847 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6848 case 'z': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6849 xproperties.set_zlim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6850 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6851 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6852 case 'c': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6853 xproperties.set_clim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6854 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6855 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6856 case 'a': |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6857 xproperties.set_alim (limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6858 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6859 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6860 default: |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6861 break; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6862 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6863 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6864 base_graphics_object::update_axis_limits (axis_type, h); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6865 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6866 } |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6867 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6868 void |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6869 hggroup::update_axis_limits (const std::string& axis_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6870 { |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6871 if (updating_hggroup_limits) |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6872 return; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6873 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6874 Matrix kids = xproperties.get_children (); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6875 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6876 double min_val = octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6877 double max_val = -octave_Inf; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6878 double min_pos = octave_Inf; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6879 double max_neg = -octave_Inf; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6880 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6881 char update_type = 0; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6882 |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
6883 if (axis_type == "xlim" || axis_type == "xliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6884 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6885 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'x'); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
6886 |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6887 update_type = 'x'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6888 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
6889 else if (axis_type == "ylim" || axis_type == "yliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6890 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6891 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'y'); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6892 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6893 update_type = 'y'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6894 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
6895 else if (axis_type == "zlim" || axis_type == "zliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6896 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6897 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'z'); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6898 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6899 update_type = 'z'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6900 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
6901 else if (axis_type == "clim" || axis_type == "climinclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6902 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6903 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'c'); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6904 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6905 update_type = 'c'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6906 } |
8081
b1634dd9ebe7
Make hggroup to react on [xyzac]liminclude changes in its children.
Michael Goffioul
parents:
8075
diff
changeset
|
6907 else if (axis_type == "alim" || axis_type == "aliminclude") |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6908 { |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6909 get_children_limits (min_val, max_val, min_pos, max_neg, kids, 'a'); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6910 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6911 update_type = 'a'; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6912 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6913 |
11175
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6914 unwind_protect frame; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6915 frame.protect_var (updating_hggroup_limits); |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6916 |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6917 updating_hggroup_limits = true; |
c0a95a5c6d25
Address the speed of plotting large hggroup groups and in particular
David Bateman <dbateman@free.fr>
parents:
11168
diff
changeset
|
6918 |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6919 Matrix limits (1, 4, 0.0); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6920 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6921 limits(0) = min_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6922 limits(1) = max_val; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6923 limits(2) = min_pos; |
13132
e3e8ca96f923
Support log scale plots with all negative data.
Ben Abbott <bpabbott@mac.com>
parents:
13130
diff
changeset
|
6924 limits(3) = max_neg; |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6925 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6926 switch (update_type) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6927 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6928 case 'x': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6929 xproperties.set_xlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6930 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6931 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6932 case 'y': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6933 xproperties.set_ylim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6934 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6935 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6936 case 'z': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6937 xproperties.set_zlim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6938 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6939 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6940 case 'c': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6941 xproperties.set_clim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6942 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6943 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6944 case 'a': |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6945 xproperties.set_alim (limits); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6946 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6947 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6948 default: |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6949 break; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6950 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6951 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6952 base_graphics_object::update_axis_limits (axis_type); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6953 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6954 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6955 // --------------------------------------------------------------------- |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
6956 |
6406 | 6957 octave_value |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6958 uicontrol::properties::get_extent (void) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6959 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6960 Matrix m = extent.get ().matrix_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6961 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
6962 graphics_object parent_obj = |
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
6963 gh_manager::get_object (get_parent ()); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6964 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6965 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6966 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6967 return convert_position (m, "pixels", get_units (), parent_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6968 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6969 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6970 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6971 uicontrol::properties::update_text_extent (void) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6972 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6973 #ifdef HAVE_FREETYPE |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6974 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6975 text_element *elt; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6976 ft_render text_renderer; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6977 Matrix box; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6978 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6979 // FIXME: parsed content should be cached for efficiency |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6980 // FIXME: support multiline text |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6981 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6982 elt = text_parser_none ().parse (get_string_string ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6983 #ifdef HAVE_FONTCONFIG |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6984 text_renderer.set_font (get_fontname (), |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
6985 get_fontweight (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
6986 get_fontangle (), |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
6987 get_fontsize ()); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6988 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6989 box = text_renderer.get_extent (elt, 0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6990 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6991 Matrix ext (1, 4, 0.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6992 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6993 // FIXME: also handle left and bottom components |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6994 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6995 ext(0) = ext(1) = 1; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6996 ext(2) = box(0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6997 ext(3) = box(1); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6998 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
6999 set_extent (ext); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7000 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7001 #endif |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7002 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7003 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7004 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7005 uicontrol::properties::update_units (void) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7006 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7007 Matrix pos = get_position ().matrix_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7008 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7009 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7010 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7011 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7012 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7013 pos = convert_position (pos, cached_units, get_units (), parent_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7014 set_position (pos); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7015 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7016 cached_units = get_units (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7017 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7018 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7019 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7020 uicontrol::properties::set_style (const octave_value& st) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7021 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7022 if (get___object__ ().is_empty()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7023 style = st; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7024 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7025 error ("set: cannot change the style of a uicontrol object after creation."); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7026 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7027 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7028 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7029 uicontrol::properties::get_boundingbox (bool, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7030 const Matrix& parent_pix_size) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7031 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7032 Matrix pos = get_position ().matrix_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7033 Matrix parent_size (parent_pix_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7034 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7035 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7036 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7037 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7038 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7039 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7040 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7041 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7042 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7043 pos = convert_position (pos, get_units (), "pixels", parent_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7044 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7045 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7046 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7047 pos(1) = parent_size(1) - pos(1) - pos(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7048 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7049 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7050 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7051 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7052 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7053 uicontrol::properties::set_fontunits (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7054 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7055 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7056 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7057 caseless_str old_fontunits = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7058 if (fontunits.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7059 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7060 update_fontunits (old_fontunits); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7061 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7062 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7063 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7064 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7065 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7066 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7067 uicontrol::properties::update_fontunits (const caseless_str& old_units) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7068 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7069 caseless_str new_units = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7070 double parent_height = get_boundingbox (false).elem (3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7071 double fsz = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7072 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7073 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7074 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7075 fontsize.set (octave_value (fsz), true); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7076 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7077 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7078 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7079 uicontrol::properties::get_fontsize_points (double box_pix_height) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7080 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7081 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7082 double parent_height = box_pix_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7083 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7084 if (fontunits_is ("normalized") && parent_height <= 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7085 parent_height = get_boundingbox (false).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7086 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7087 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7088 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7089 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7090 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7091 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7092 Matrix |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7093 uipanel::properties::get_boundingbox (bool internal, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7094 const Matrix& parent_pix_size) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7095 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7096 Matrix pos = get_position ().matrix_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7097 Matrix parent_size (parent_pix_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7098 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7099 if (parent_size.numel () == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7100 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7101 graphics_object obj = gh_manager::get_object (get_parent ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7102 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7103 parent_size = |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7104 obj.get_properties ().get_boundingbox (true).extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7105 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7106 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7107 pos = convert_position (pos, get_units (), "pixels", parent_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7108 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7109 pos(0)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7110 pos(1)--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7111 pos(1) = parent_size(1) - pos(1) - pos(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7112 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7113 if (internal) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7114 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7115 double outer_height = pos(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7116 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7117 pos(0) = pos(1) = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7118 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7119 if (! bordertype_is ("none")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7120 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7121 double bw = get_borderwidth (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7122 double mul = 1.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7123 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7124 if (bordertype_is ("etchedin") || bordertype_is ("etchedout")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7125 mul = 2.0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7126 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7127 pos(0) += mul * bw; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7128 pos(1) += mul * bw; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7129 pos(2) -= 2 * mul * bw; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7130 pos(3) -= 2 * mul * bw; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7131 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7132 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7133 if (! get_title ().empty ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7134 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7135 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7136 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7137 if (! fontunits_is ("pixels")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7138 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7139 double res = xget (0, "screenpixelsperinch").double_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7140 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7141 if (fontunits_is ("points")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7142 fs *= (res / 72.0); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7143 else if (fontunits_is ("inches")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7144 fs *= res; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7145 else if (fontunits_is ("centimeters")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7146 fs *= (res / 2.54); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7147 else if (fontunits_is ("normalized")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7148 fs *= outer_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7149 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7150 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7151 if (titleposition_is ("lefttop") || titleposition_is ("centertop") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7152 || titleposition_is ("righttop")) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7153 pos(1) += (fs / 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7154 pos(3) -= (fs / 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7155 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7156 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7157 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7158 return pos; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7159 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7160 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7161 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7162 uipanel::properties::set_units (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7163 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7164 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7165 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7166 caseless_str old_units = get_units (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7167 if (units.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7168 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7169 update_units (old_units); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7170 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7171 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7172 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7173 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7174 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7175 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7176 uipanel::properties::update_units (const caseless_str& old_units) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7177 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7178 Matrix pos = get_position ().matrix_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7179 |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7180 graphics_object parent_obj = gh_manager::get_object (get_parent ()); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7181 Matrix parent_bbox = parent_obj.get_properties ().get_boundingbox (true), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7182 parent_size = parent_bbox.extract_n (0, 2, 1, 2); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7183 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7184 pos = convert_position (pos, old_units, get_units (), parent_size); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7185 set_position (pos); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7186 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7187 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7188 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7189 uipanel::properties::set_fontunits (const octave_value& v) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7190 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7191 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7192 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7193 caseless_str old_fontunits = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7194 if (fontunits.set (v, true)) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7195 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7196 update_fontunits (old_fontunits); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7197 mark_modified (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7198 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7199 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7200 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7201 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7202 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7203 uipanel::properties::update_fontunits (const caseless_str& old_units) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7204 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7205 caseless_str new_units = get_fontunits (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7206 double parent_height = get_boundingbox (false).elem (3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7207 double fsz = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7208 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7209 fsz = convert_font_size (fsz, old_units, new_units, parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7210 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7211 set_fontsize (octave_value (fsz)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7212 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7213 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7214 double |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7215 uipanel::properties::get_fontsize_points (double box_pix_height) const |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7216 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7217 double fs = get_fontsize (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7218 double parent_height = box_pix_height; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7219 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7220 if (fontunits_is ("normalized") && parent_height <= 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7221 parent_height = get_boundingbox (false).elem(3); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7222 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7223 return convert_font_size (fs, get_fontunits (), "points", parent_height); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7224 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7225 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7226 // --------------------------------------------------------------------- |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7227 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7228 octave_value |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7229 uitoolbar::get_default (const caseless_str& name) const |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7230 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7231 octave_value retval = default_properties.lookup (name); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7232 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7233 if (retval.is_undefined ()) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7234 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7235 graphics_handle parent = get_parent (); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7236 graphics_object parent_obj = gh_manager::get_object (parent); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7237 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7238 retval = parent_obj.get_default (name); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7239 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7240 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7241 return retval; |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7242 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7243 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7244 void |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7245 uitoolbar::reset_default_properties (void) |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7246 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7247 ::reset_default_properties (default_properties); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7248 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7249 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7250 // --------------------------------------------------------------------- |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7251 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7252 octave_value |
7189 | 7253 base_graphics_object::get_default (const caseless_str& name) const |
6406 | 7254 { |
7255 graphics_handle parent = get_parent (); | |
7256 graphics_object parent_obj = gh_manager::get_object (parent); | |
7257 | |
7258 return parent_obj.get_default (type () + name); | |
7259 } | |
7260 | |
7261 octave_value | |
7189 | 7262 base_graphics_object::get_factory_default (const caseless_str& name) const |
6406 | 7263 { |
7264 graphics_object parent_obj = gh_manager::get_object (0); | |
7265 | |
7266 return parent_obj.get_factory_default (type () + name); | |
7267 } | |
7268 | |
7286 | 7269 // We use a random value for the handle to avoid issues with plots and |
7270 // scalar values for the first argument. | |
6406 | 7271 gh_manager::gh_manager (void) |
7286 | 7272 : handle_map (), handle_free_list (), |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7273 next_handle (-1.0 - (rand () + 1.0) / (RAND_MAX + 2.0)), |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7274 figure_list (), graphics_lock (), event_queue (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7275 callback_objects (), event_processing (0) |
6406 | 7276 { |
7277 handle_map[0] = graphics_object (new root_figure ()); | |
7847
40b16e04172a
Make backend switching work.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7844
diff
changeset
|
7278 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7279 // Make sure the default graphics toolkit is registered. |
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7280 graphics_toolkit::default_toolkit (); |
6406 | 7281 } |
7282 | |
7283 graphics_handle | |
7284 gh_manager::do_make_graphics_handle (const std::string& go_name, | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7285 const graphics_handle& p, bool do_createfcn, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7286 bool do_notify_toolkit) |
6406 | 7287 { |
7288 graphics_handle h = get_handle (go_name); | |
7289 | |
7290 base_graphics_object *go = 0; | |
7291 | |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
7292 go = make_graphics_object_from_type (go_name, h, p); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7293 |
6406 | 7294 if (go) |
7370 | 7295 { |
8059
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7296 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7297 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7298 handle_map[h] = obj; |
7370 | 7299 if (do_createfcn) |
7300 go->get_properties ().execute_createfcn (); | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7301 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7302 // Notify graphics toolkit. |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7303 if (do_notify_toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7304 obj.initialize (); |
7370 | 7305 } |
6406 | 7306 else |
7307 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
|
7308 go_name.c_str ()); |
6406 | 7309 |
7310 return h; | |
7311 } | |
7312 | |
7313 graphics_handle | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7314 gh_manager::do_make_figure_handle (double val, bool do_notify_toolkit) |
6406 | 7315 { |
7316 graphics_handle h = val; | |
7317 | |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7318 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
|
7319 graphics_object obj (go); |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7320 |
75c99d3f97d7
Octave to backend notification scheme
John W. Eaton <jwe@octave.org>
parents:
8058
diff
changeset
|
7321 handle_map[h] = obj; |
8058
ca39c21fa4b8
[mq]: generic_octave_to_backend_nofitication
John W. Eaton <jwe@octave.org>
parents:
8052
diff
changeset
|
7322 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
7323 // Notify graphics toolkit. |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7324 if (do_notify_toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7325 obj.initialize (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7326 |
6406 | 7327 return h; |
7328 } | |
7329 | |
7330 void | |
7331 gh_manager::do_push_figure (const graphics_handle& h) | |
7332 { | |
7333 do_pop_figure (h); | |
7334 | |
7335 figure_list.push_front (h); | |
7336 } | |
7337 | |
7338 void | |
7339 gh_manager::do_pop_figure (const graphics_handle& h) | |
7340 { | |
7341 for (figure_list_iterator p = figure_list.begin (); | |
7342 p != figure_list.end (); | |
7343 p++) | |
7344 { | |
7345 if (*p == h) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7346 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7347 figure_list.erase (p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7348 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7349 } |
6406 | 7350 } |
7351 } | |
7352 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7353 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7354 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
|
7355 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7356 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7357 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
|
7358 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
|
7359 : base_graphics_event (), handle (h), callback_name (name), |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7360 callback (), callback_data (data) { } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7361 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7362 callback_event (const graphics_handle& h, const octave_value& cb, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7363 const octave_value& data = Matrix ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7364 : base_graphics_event (), handle (h), callback_name (), |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7365 callback (cb), callback_data (data) { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7366 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7367 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7368 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7369 if (callback.is_defined ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7370 gh_manager::execute_callback (handle, callback, callback_data); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7371 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7372 gh_manager::execute_callback (handle, callback_name, callback_data); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7373 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7374 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7375 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7376 callback_event (void) |
12174 | 7377 : base_graphics_event (), handle (), |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7378 callback_name (), callback_data () |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7379 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7380 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7381 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7382 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7383 std::string callback_name; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7384 octave_value callback; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7385 octave_value callback_data; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7386 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7387 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7388 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7389 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
|
7390 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7391 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7392 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
|
7393 : base_graphics_event (), function (fcn), |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7394 function_data (data) { } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7395 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7396 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7397 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7398 function (function_data); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7399 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7400 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7401 private: |
12174 | 7402 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7403 graphics_event::event_fcn function; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7404 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7405 void* function_data; |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7406 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7407 // function_event objects must be created with at least a function. |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7408 function_event (void); |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7409 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7410 // No copying! |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7411 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7412 function_event (const function_event &); |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7413 |
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7414 function_event & operator = (const function_event &); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7415 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7416 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7417 class |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7418 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
|
7419 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7420 public: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7421 set_event (const graphics_handle& h, const std::string& name, |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7422 const octave_value& value, bool do_notify_toolkit = true) |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7423 : base_graphics_event (), handle (h), property_name (name), |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7424 property_value (value), notify_toolkit (do_notify_toolkit) { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7425 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7426 void execute (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7427 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7428 gh_manager::auto_lock guard; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7429 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7430 graphics_object go = gh_manager::get_object (handle); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7431 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7432 if (go) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7433 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7434 property p = go.get_properties ().get_property (property_name); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7435 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7436 if (p.ok ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7437 p.set (property_value, true, notify_toolkit); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7438 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7439 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7440 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7441 private: |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7442 set_event (void) |
12174 | 7443 : base_graphics_event (), handle (), property_name (), property_value () |
12164
18e9a8da7d18
eliminate some -Weffc++ warnings
Pascal Dupuis <Pascal.Dupuis@uclouvain.be>
parents:
12159
diff
changeset
|
7444 { } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7445 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7446 private: |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7447 graphics_handle handle; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7448 std::string property_name; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7449 octave_value property_value; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7450 bool notify_toolkit; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7451 }; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7452 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7453 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7454 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
|
7455 const std::string& name, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7456 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7457 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7458 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7459 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7460 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
|
7461 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7462 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7463 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7464 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7465 graphics_event |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7466 graphics_event::create_callback_event (const graphics_handle& h, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7467 const octave_value& cb, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7468 const octave_value& data) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7469 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7470 graphics_event e; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7471 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7472 e.rep = new callback_event (h, cb, data); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7473 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7474 return e; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7475 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7476 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7477 graphics_event |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7478 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
|
7479 void *data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7480 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7481 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7482 |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7483 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
|
7484 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7485 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7486 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7487 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7488 graphics_event |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7489 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
|
7490 const std::string& name, |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7491 const octave_value& data, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7492 bool notify_toolkit) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7493 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7494 graphics_event e; |
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7495 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7496 e.rep = new set_event (h, name, data, notify_toolkit); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7497 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7498 return e; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7499 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7500 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7501 static void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7502 xset_gcbo (const graphics_handle& h) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7503 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7504 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
|
7505 root_figure::properties& props = |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7506 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
|
7507 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7508 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
|
7509 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7510 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7511 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7512 gh_manager::do_restore_gcbo (void) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7513 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7514 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7515 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7516 callback_objects.pop_front (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7517 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7518 xset_gcbo (callback_objects.empty () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7519 ? graphics_handle () |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7520 : callback_objects.front ().get_handle ()); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7521 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7522 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7523 void |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7524 gh_manager::do_execute_listener (const graphics_handle& h, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7525 const octave_value& l) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7526 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7527 if (octave_thread::is_octave_thread ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7528 gh_manager::execute_callback (h, l, octave_value ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7529 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7530 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7531 gh_manager::auto_lock guard; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7532 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7533 do_post_event (graphics_event::create_callback_event (h, l)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7534 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7535 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7536 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7537 void |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7538 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
|
7539 const octave_value& cb_arg, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7540 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7541 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7542 if (cb_arg.is_defined () && ! cb_arg.is_empty ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7543 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7544 octave_value_list args; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7545 octave_function *fcn = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7546 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7547 args(0) = h.as_octave_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7548 if (data.is_defined ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7549 args(1) = data; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7550 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7551 args(1) = Matrix (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7552 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7553 unwind_protect_safe frame; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7554 frame.add_fcn (gh_manager::restore_gcbo); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7555 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7556 if (true) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7557 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7558 gh_manager::auto_lock guard; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7559 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7560 callback_objects.push_front (get_object (h)); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7561 xset_gcbo (h); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7562 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7563 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7564 BEGIN_INTERRUPT_WITH_EXCEPTIONS; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7565 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7566 // Copy CB because "function_value" method is non-const. |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7567 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7568 octave_value cb = cb_arg; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7569 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7570 if (cb.is_function_handle ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7571 fcn = cb.function_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7572 else if (cb.is_string ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7573 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7574 int status; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7575 std::string s = cb.string_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7576 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7577 eval_string (s, false, status); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7578 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7579 else if (cb.is_cell () && cb.length () > 0 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7580 && (cb.rows () == 1 || cb.columns () == 1) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7581 && cb.cell_value ()(0).is_function_handle ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7582 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7583 Cell c = cb.cell_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7584 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7585 fcn = c(0).function_value (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7586 if (! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7587 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7588 for (int i = 1; i < c.length () ; i++) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7589 args(1+i) = c(i); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7590 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7591 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7592 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7593 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7594 std::string nm = cb.class_name (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7595 error ("trying to execute non-executable object (class = %s)", |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7596 nm.c_str ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7597 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7598 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7599 if (fcn && ! error_state) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7600 feval (fcn, args); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7601 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7602 END_INTERRUPT_WITH_EXCEPTIONS; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7603 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7604 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7605 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7606 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7607 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
|
7608 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7609 event_queue.push_back (e); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7610 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7611 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
|
7612 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7613 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7614 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7615 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
|
7616 const octave_value& data) |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7617 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7618 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7619 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7620 graphics_object go = get_object (h); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7621 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7622 if (go.valid_object ()) |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7623 { |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7624 if (callback_objects.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7625 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
|
7626 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7627 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7628 const graphics_object& current = callback_objects.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7629 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7630 if (current.get_properties ().is_interruptible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7631 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
|
7632 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7633 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7634 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
|
7635 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7636 if (busy_action.compare ("queue")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7637 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
|
7638 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7639 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7640 caseless_str cname (name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7641 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7642 if (cname.compare ("deletefcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7643 || cname.compare ("createfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7644 || (go.isa ("figure") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7645 && (cname.compare ("closerequestfcn") |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7646 || cname.compare ("resizefcn")))) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7647 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
|
7648 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7649 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7650 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7651 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7652 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7653 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7654 void |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7655 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
|
7656 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7657 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7658 |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7659 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
|
7660 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7661 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7662 void |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7663 gh_manager::do_post_set (const graphics_handle& h, const std::string name, |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7664 const octave_value& value, bool notify_toolkit) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7665 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7666 gh_manager::auto_lock guard; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7667 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7668 do_post_event (graphics_event::create_set_event (h, name, value, |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7669 notify_toolkit)); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7670 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7671 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7672 int |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7673 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
|
7674 { |
7964
9cd3ee5298a0
Use common rep/class pattern for graphics events
John W. Eaton <jwe@octave.org>
parents:
7936
diff
changeset
|
7675 graphics_event e; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7676 bool old_Vdrawnow_requested = Vdrawnow_requested; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7677 unwind_protect frame; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7678 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7679 static int process_events_executing = 0; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7680 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7681 frame.protect_var (process_events_executing); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7682 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7683 if (++process_events_executing <= 1) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7684 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7685 do |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7686 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7687 e = graphics_event (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7688 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7689 gh_manager::lock (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7690 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7691 if (! event_queue.empty ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7692 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7693 if (callback_objects.empty () || force) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7694 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7695 e = event_queue.front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7696 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7697 event_queue.pop_front (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7698 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7699 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7700 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7701 const graphics_object& go = callback_objects.front (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7702 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7703 if (go.get_properties ().is_interruptible ()) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7704 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7705 e = event_queue.front (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7706 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7707 event_queue.pop_front (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7708 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7709 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7710 } |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7711 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7712 gh_manager::unlock (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7713 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7714 if (e.ok ()) |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7715 e.execute (); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7716 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7717 while (e.ok ()); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7718 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7719 gh_manager::lock (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7720 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7721 if (event_queue.empty () && event_processing == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7722 command_editor::remove_event_hook (gh_manager::process_events); |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7723 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7724 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7725 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7726 flush_octave_stdout (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7727 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7728 if (Vdrawnow_requested && ! old_Vdrawnow_requested) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7729 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7730 feval ("drawnow"); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7731 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7732 Vdrawnow_requested = false; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7733 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7734 } |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7735 |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7736 return 0; |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7737 } |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7738 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7739 void |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7740 gh_manager::do_enable_event_processing (bool enable) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7741 { |
13736
deb69dab4514
Avoid some compilation warnings.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13713
diff
changeset
|
7742 gh_manager::auto_lock guard; |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7743 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7744 if (enable) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7745 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7746 event_processing++; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7747 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7748 command_editor::add_event_hook (gh_manager::process_events); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7749 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7750 else |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7751 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7752 event_processing--; |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7753 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7754 if (event_queue.empty () && event_processing == 0) |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7755 command_editor::remove_event_hook (gh_manager::process_events); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7756 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7757 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7758 |
6406 | 7759 property_list::plist_map_type |
7760 root_figure::init_factory_properties (void) | |
7761 { | |
7762 property_list::plist_map_type plist_map; | |
7763 | |
6844 | 7764 plist_map["figure"] = figure::properties::factory_defaults (); |
7765 plist_map["axes"] = axes::properties::factory_defaults (); | |
7766 plist_map["line"] = line::properties::factory_defaults (); | |
7767 plist_map["text"] = text::properties::factory_defaults (); | |
7768 plist_map["image"] = image::properties::factory_defaults (); | |
7769 plist_map["patch"] = patch::properties::factory_defaults (); | |
7770 plist_map["surface"] = surface::properties::factory_defaults (); | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
7771 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
|
7772 plist_map["uimenu"] = uimenu::properties::factory_defaults (); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7773 plist_map["uicontrol"] = uicontrol::properties::factory_defaults (); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7774 plist_map["uipanel"] = uipanel::properties::factory_defaults (); |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7775 plist_map["uicontextmenu"] = uicontextmenu::properties::factory_defaults (); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7776 plist_map["uitoolbar"] = uitoolbar::properties::factory_defaults (); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7777 plist_map["uipushtool"] = uipushtool::properties::factory_defaults (); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
7778 plist_map["uitoggletool"] = uitoggletool::properties::factory_defaults (); |
6406 | 7779 |
7780 return plist_map; | |
7781 } | |
7782 | |
7783 // --------------------------------------------------------------------- | |
7784 | |
7785 DEFUN (ishandle, args, , | |
7786 "-*- texinfo -*-\n\ | |
6678 | 7787 @deftypefn {Built-in Function} {} ishandle (@var{h})\n\ |
6406 | 7788 Return true if @var{h} is a graphics handle and false otherwise.\n\ |
11431
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7789 @var{h} may also be a matrix of handles in which case a logical\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7790 array is returned that is true where the elements of @var{h} are\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7791 graphics handles and false where they are not.\n\ |
0d9640d755b1
Improve docstrings for all isXXX functions.
Rik <octave@nomad.inbox5.com>
parents:
11385
diff
changeset
|
7792 @seealso{isfigure}\n\ |
6406 | 7793 @end deftypefn") |
7794 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7795 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7796 |
6406 | 7797 octave_value retval; |
7798 | |
7799 if (args.length () == 1) | |
7800 retval = is_handle (args(0)); | |
7801 else | |
7802 print_usage (); | |
7803 | |
7804 return retval; | |
7805 } | |
7806 | |
13327
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7807 static bool |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7808 is_handle_visible (const graphics_handle& h) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7809 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7810 return h.ok () && gh_manager::is_handle_visible (h); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7811 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7812 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7813 static bool |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7814 is_handle_visible (double val) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7815 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7816 return is_handle_visible (gh_manager::lookup (val)); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7817 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7818 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7819 static octave_value |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7820 is_handle_visible (const octave_value& val) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7821 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7822 octave_value retval = false; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7823 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7824 if (val.is_real_scalar () && is_handle_visible (val.double_value ())) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7825 retval = true; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7826 else if (val.is_numeric_type () && val.is_real_type ()) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7827 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7828 const NDArray handles = val.array_value (); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7829 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7830 if (! error_state) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7831 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7832 boolNDArray result (handles.dims ()); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7833 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7834 for (octave_idx_type i = 0; i < handles.numel (); i++) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7835 result.xelem (i) = is_handle_visible (handles (i)); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7836 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7837 retval = result; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7838 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7839 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7840 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7841 return retval; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7842 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7843 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7844 DEFUN (__is_handle_visible__, args, , |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7845 "-*- texinfo -*-\n\ |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7846 @deftypefn {Built-in Function} __is_handle_visible__ (@var{h})\n\ |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7847 Undocumented internal function.\n\ |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7848 @end deftypefn") |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7849 { |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7850 octave_value retval; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7851 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7852 if (args.length () == 1) |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7853 retval = is_handle_visible (args(0)); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7854 else |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7855 print_usage (); |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7856 |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7857 return retval; |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7858 } |
f81fcceb394c
axes: only update the currentaxes property of the parent figure if the axes object is visible
John W. Eaton <jwe@octave.org>
parents:
13324
diff
changeset
|
7859 |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7860 DEFUN (reset, args, , |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7861 "-*- texinfo -*-\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7862 @deftypefn {Built-in Function} {} reset (@var{h}, @var{property})\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
7863 Remove any defaults set for the handle @var{h}. The default figure\n\ |
12189
9558ca33648d
Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
7864 properties of \"position\", \"units\", \"windowstyle\" and\n\ |
9558ca33648d
Add functions reset, whitebg to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12174
diff
changeset
|
7865 \"paperunits\" and the default axes properties of \"position\" and \"units\"\n\ |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7866 are not reset.\n\ |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7867 @end deftypefn") |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7868 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7869 int nargin = args.length (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7870 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7871 if (nargin != 1) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7872 print_usage (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7873 else |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7874 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7875 // get vector of graphics handles |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7876 ColumnVector hcv (args(0).vector_value ()); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7877 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7878 if (! error_state) |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7879 { |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7880 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7881 for (octave_idx_type n = 0; n < hcv.length (); n++) |
10722
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7882 gh_manager::get_object (hcv(n)).reset_default_properties (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7883 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7884 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7885 |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7886 return octave_value (); |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7887 } |
755fcb5baad3
Add the reset built function
David Bateman <dbateman@free.fr>
parents:
10717
diff
changeset
|
7888 |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7889 DEFUN (set, args, nargout, |
6406 | 7890 "-*- texinfo -*-\n\ |
10840 | 7891 @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
|
7892 @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
|
7893 @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
|
7894 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
|
7895 handles) @var{h}.\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7896 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
|
7897 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7898 @itemize\n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7899 @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
|
7900 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7901 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
|
7902 @var{value} is a value of the appropriate type for the property.\n\ |
10840 | 7903 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7904 @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
|
7905 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
|
7906 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7907 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
|
7908 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
|
7909 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
|
7910 @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
|
7911 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
|
7912 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
|
7913 the first row of @var{values} and so on.\n\ |
10840 | 7914 \n\ |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7915 @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
|
7916 \n\ |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7917 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
|
7918 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
|
7919 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
|
7920 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
|
7921 @end itemize\n\ |
6406 | 7922 @end deftypefn") |
7923 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
7924 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
7925 |
6406 | 7926 octave_value retval; |
7927 | |
7928 int nargin = args.length (); | |
7929 | |
7930 if (nargin > 0) | |
7931 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7932 // get vector of graphics handles |
6732 | 7933 ColumnVector hcv (args(0).vector_value ()); |
6406 | 7934 |
7935 if (! error_state) | |
6732 | 7936 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7937 bool request_drawnow = false; |
6733 | 7938 |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7939 // loop over graphics objects |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
7940 for (octave_idx_type n = 0; n < hcv.length (); n++) |
6732 | 7941 { |
7942 graphics_object obj = gh_manager::get_object (hcv(n)); | |
6406 | 7943 |
6732 | 7944 if (obj) |
7945 { | |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7946 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
|
7947 && args(2).is_cell ()) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7948 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7949 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
|
7950 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7951 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
|
7952 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
|
7953 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7954 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
|
7955 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7956 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
|
7957 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
|
7958 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7959 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7960 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7961 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
|
7962 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
|
7963 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7964 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7965 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7966 } |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7967 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
|
7968 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7969 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
|
7970 } |
10717
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7971 else if (nargin == 1) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7972 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7973 if (nargout != 0) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7974 retval = obj.values_as_struct (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7975 else |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7976 { |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7977 std::string s = obj.values_as_string (); |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7978 if (! error_state) |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7979 octave_stdout << s; |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7980 } |
9d4a198614ab
Add functionality set(handle)
David Bateman <dbateman@free.fr>
parents:
10711
diff
changeset
|
7981 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7982 else |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7983 { |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7984 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
|
7985 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7986 } |
6732 | 7987 } |
7988 else | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7989 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7990 error ("set: invalid handle (= %g)", hcv(n)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7991 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
7992 } |
10056
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7993 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7994 if (error_state) |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7995 break; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7996 |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7997 request_drawnow = true; |
33ba83a06a42
Fix set function to allow cell and struct arguments.
Thorsten Meyer <thorsten.meyier@gmx.de>
parents:
9972
diff
changeset
|
7998 } |
6733 | 7999 |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8000 if (! error_state && request_drawnow) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8001 Vdrawnow_requested = true; |
6732 | 8002 } |
6406 | 8003 else |
6732 | 8004 error ("set: expecting graphics handle as first argument"); |
6406 | 8005 } |
8006 else | |
8007 print_usage (); | |
8008 | |
8009 return retval; | |
8010 } | |
8011 | |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8012 static std::string |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8013 get_graphics_object_type (const double val) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8014 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8015 std::string retval; |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8016 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8017 graphics_object obj = gh_manager::get_object (val); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8018 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8019 if (obj) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8020 retval = obj.type (); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8021 else |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8022 error ("get: invalid handle (= %g)", val); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8023 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8024 return retval; |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8025 } |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8026 |
6406 | 8027 DEFUN (get, args, , |
8028 "-*- texinfo -*-\n\ | |
6678 | 8029 @deftypefn {Built-in Function} {} get (@var{h}, @var{p})\n\ |
6406 | 8030 Return the named property @var{p} from the graphics handle @var{h}.\n\ |
8031 If @var{p} is omitted, return the complete property list for @var{h}.\n\ | |
6732 | 8032 If @var{h} is a vector, return a cell array including the property\n\ |
8033 values or lists respectively.\n\ | |
6406 | 8034 @end deftypefn") |
8035 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8036 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8037 |
6406 | 8038 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
|
8039 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8040 Cell vals; |
6406 | 8041 |
8042 int nargin = args.length (); | |
8043 | |
8044 if (nargin == 1 || nargin == 2) | |
8045 { | |
12678
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8046 if (args(0).is_empty()) |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8047 { |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8048 retval = Matrix (); |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8049 return retval; |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8050 } |
69cd5ebe5fb5
Stop obscure warnings when get() called with null matrix input (bug #32642)
Rik <octave@nomad.inbox5.com>
parents:
12587
diff
changeset
|
8051 |
6732 | 8052 ColumnVector hcv (args(0).vector_value ()); |
6406 | 8053 |
8054 if (! error_state) | |
6732 | 8055 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8056 octave_idx_type len = hcv.length (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8057 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8058 vals.resize (dim_vector (len, 1)); |
6733 | 8059 |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8060 if (nargin == 1 && len > 1) |
6732 | 8061 { |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8062 std::string t0 = get_graphics_object_type (hcv(0)); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8063 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8064 if (! error_state) |
6732 | 8065 { |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8066 for (octave_idx_type n = 1; n < len; n++) |
6732 | 8067 { |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8068 std::string t = get_graphics_object_type (hcv(n)); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8069 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8070 if (error_state) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8071 break; |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8072 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8073 if (t != t0) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8074 { |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8075 error ("get: vector of handles must all have same type"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8076 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8077 } |
6732 | 8078 } |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8079 |
6732 | 8080 } |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8081 } |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8082 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8083 if (! error_state) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8084 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8085 for (octave_idx_type n = 0; n < len; n++) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8086 { |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8087 graphics_object obj = gh_manager::get_object (hcv(n)); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8088 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8089 if (obj) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8090 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8091 if (nargin == 1) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8092 vals(n) = obj.get (); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8093 else |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8094 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8095 caseless_str property = args(1).string_value (); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8096 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8097 if (! error_state) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8098 vals(n) = obj.get (property); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8099 else |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8100 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8101 error ("get: expecting property name as second argument"); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8102 break; |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8103 } |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8104 } |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8105 } |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8106 else |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8107 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8108 error ("get: invalid handle (= %g)", hcv(n)); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8109 break; |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8110 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8111 } |
6732 | 8112 } |
8113 } | |
6406 | 8114 else |
6732 | 8115 error ("get: expecting graphics handle as first argument"); |
6406 | 8116 } |
8117 else | |
8118 print_usage (); | |
8119 | |
6733 | 8120 if (! error_state) |
6732 | 8121 { |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8122 octave_idx_type len = vals.numel (); |
6733 | 8123 |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8124 if (len == 0) |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8125 retval = Matrix (); |
6733 | 8126 else if (len == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8127 retval = vals(0); |
13210
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8128 else if (len > 1 && nargin == 1) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8129 { |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8130 OCTAVE_LOCAL_BUFFER (octave_scalar_map, tmp, len); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8131 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8132 for (octave_idx_type n = 0; n < len; n++) |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8133 tmp[n] = vals(n).scalar_map_value (); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8134 |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8135 retval = octave_map::cat (0, len, tmp); |
d0f9d7353ee5
return get(h) as a struct array when h is a vector of handles
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
8136 } |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8137 else |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8138 retval = vals; |
6732 | 8139 } |
8140 | |
6406 | 8141 return retval; |
8142 } | |
8143 | |
11456
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8144 /* |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8145 %!assert (get (findobj (0, 'Tag', 'nonexistenttag'), 'nonexistentproperty'), []) |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8146 */ |
fbdb95640852
get: return empty matrix if no values are found
John W. Eaton <jwe@octave.org>
parents:
11455
diff
changeset
|
8147 |
8812
7d48766c21a5
use consistent format for doc strings of internal functions
John W. Eaton <jwe@octave.org>
parents:
8740
diff
changeset
|
8148 // 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
|
8149 // 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
|
8150 // 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
|
8151 |
7379 | 8152 DEFUN (__get__, args, , |
8153 "-*- texinfo -*-\n\ | |
8154 @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
|
8155 Undocumented internal function.\n\ |
7379 | 8156 @end deftypefn") |
8157 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8158 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8159 |
7379 | 8160 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
|
8161 |
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8162 Cell vals; |
7379 | 8163 |
8164 int nargin = args.length (); | |
8165 | |
8166 if (nargin == 1) | |
8167 { | |
8168 ColumnVector hcv (args(0).vector_value ()); | |
8169 | |
8170 if (! error_state) | |
8171 { | |
8172 octave_idx_type len = hcv.length (); | |
8173 | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8174 vals.resize (dim_vector (len, 1)); |
7379 | 8175 |
8176 for (octave_idx_type n = 0; n < len; n++) | |
8177 { | |
8178 graphics_object obj = gh_manager::get_object (hcv(n)); | |
8179 | |
8180 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
|
8181 vals(n) = obj.get (true); |
7379 | 8182 else |
8183 { | |
8184 error ("get: invalid handle (= %g)", hcv(n)); | |
8185 break; | |
8186 } | |
8187 } | |
8188 } | |
8189 else | |
8190 error ("get: expecting graphics handle as first argument"); | |
8191 } | |
8192 else | |
8193 print_usage (); | |
8194 | |
8195 if (! error_state) | |
8196 { | |
8896
f155e9d1f086
graphics.cc (Fget, F__get__): return column vector, not row vector
John W. Eaton <jwe@octave.org>
parents:
8812
diff
changeset
|
8197 octave_idx_type len = vals.numel (); |
7379 | 8198 |
8199 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
|
8200 retval = vals; |
7379 | 8201 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
|
8202 retval = vals(0); |
7379 | 8203 } |
8204 | |
8205 return retval; | |
8206 } | |
8207 | |
6406 | 8208 static octave_value |
8209 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
|
8210 const octave_value_list& args) |
6406 | 8211 { |
8212 octave_value retval; | |
8213 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8214 double val = octave_NaN; |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8215 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8216 octave_value_list xargs = args.splice (0, 1); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8217 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8218 caseless_str p ("parent"); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8219 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8220 for (int i = 0; i < xargs.length (); i++) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8221 if (xargs(i).is_string () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8222 && p.compare (xargs(i).string_value ())) |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8223 { |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8224 if (i < (xargs.length () - 1)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8225 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8226 val = xargs(i+1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8227 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8228 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8229 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8230 xargs = xargs.splice (i, 2); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8231 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8232 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8233 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8234 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8235 error ("__go_%s__: missing value for parent property", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8236 go_name.c_str ()); |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8237 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8238 |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8239 if (! error_state && xisnan (val)) |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8240 val = args(0).double_value (); |
6406 | 8241 |
8242 if (! error_state) | |
8243 { | |
8244 graphics_handle parent = gh_manager::lookup (val); | |
8245 | |
7056 | 8246 if (parent.ok ()) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8247 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8248 graphics_handle h |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8249 = gh_manager::make_graphics_handle (go_name, parent, false, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8250 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8251 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8252 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8253 adopt (parent, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8254 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8255 xset (h, xargs); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8256 xcreatefcn (h); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8257 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8258 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8259 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8260 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8261 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8262 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8263 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8264 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8265 error ("__go%s__: unable to create graphics handle", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8266 go_name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8267 } |
6406 | 8268 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8269 error ("__go_%s__: invalid parent", go_name.c_str ()); |
6406 | 8270 } |
8271 else | |
8272 error ("__go_%s__: invalid parent", go_name.c_str ()); | |
8273 | |
8274 return retval; | |
8275 } | |
8276 | |
8277 DEFUN (__go_figure__, args, , | |
8278 "-*- texinfo -*-\n\ | |
8279 @deftypefn {Built-in Function} {} __go_figure__ (@var{fignum})\n\ | |
6945 | 8280 Undocumented internal function.\n\ |
6406 | 8281 @end deftypefn") |
8282 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8283 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8284 |
6406 | 8285 octave_value retval; |
8286 | |
8287 if (args.length () > 0) | |
8288 { | |
8289 double val = args(0).double_value (); | |
8290 | |
8291 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8292 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8293 if (is_figure (val)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8294 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8295 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8296 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8297 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8298 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8299 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8300 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8301 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8302 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8303 graphics_handle h = octave_NaN; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8304 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8305 if (xisnan (val)) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8306 h = gh_manager::make_graphics_handle ("figure", 0, false, |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8307 false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8308 else if (val > 0 && D_NINT (val) == val) |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8309 h = gh_manager::make_figure_handle (val, false); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8310 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8311 error ("__go_figure__: invalid figure number"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8312 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8313 if (! error_state && h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8314 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8315 adopt (0, h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8316 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8317 xset (h, args.splice (0, 1)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8318 xcreatefcn (h); |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8319 xinitialize (h); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8320 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8321 retval = h.value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8322 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8323 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8324 error ("__go_figure__: failed to create figure handle"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8325 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8326 } |
6406 | 8327 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8328 error ("__go_figure__: expecting figure number to be double value"); |
6406 | 8329 } |
8330 else | |
8331 print_usage (); | |
8332 | |
8333 return retval; | |
8334 } | |
8335 | |
8336 #define GO_BODY(TYPE) \ | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8337 gh_manager::auto_lock guard; \ |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8338 \ |
6406 | 8339 octave_value retval; \ |
8340 \ | |
8341 if (args.length () > 0) \ | |
8342 retval = make_graphics_object (#TYPE, args); \ | |
8343 else \ | |
8344 print_usage (); \ | |
8345 \ | |
8346 return retval | |
8347 | |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8348 int |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8349 calc_dimensions (const graphics_object& go) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8350 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8351 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8352 int nd = 2; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8353 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8354 if (go.isa ("surface")) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8355 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8356 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8357 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
|
8358 nd = 3; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8359 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8360 Matrix kids = go.get_properties().get_children (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8361 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8362 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
|
8363 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8364 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
|
8365 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8366 if (hnd.ok ()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8367 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8368 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
|
8369 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8370 if (kid.valid_object()) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8371 nd = calc_dimensions (kid); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8372 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8373 if (nd == 3) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8374 break; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8375 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8376 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8377 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8378 return nd; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8379 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8380 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8381 DEFUN (__calc_dimensions__, args, , |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8382 "-*- texinfo -*-\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8383 @deftypefn {Built-in Function} {} __calc_dimensions__ (@var{axes})\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
8384 Internal function. Determine the number of dimensions in a graphics\n\ |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8385 object, whether 2 or 3.\n\ |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8386 @end deftypefn") |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8387 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8388 gh_manager::auto_lock guard; |
10917
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8389 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8390 octave_value retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8391 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8392 int nargin = args.length (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8393 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8394 if (nargin == 1) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8395 { |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8396 double h = args(0).double_value (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8397 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8398 if (! error_state) |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8399 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
|
8400 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8401 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
|
8402 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8403 else |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8404 print_usage (); |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8405 |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8406 return retval; |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8407 } |
888c75785221
Improvements to FLTK backend rotation
Jordi Guti?rrez Hermoso <jordigh@gmail.com>
parents:
10846
diff
changeset
|
8408 |
6406 | 8409 DEFUN (__go_axes__, args, , |
8410 "-*- texinfo -*-\n\ | |
8411 @deftypefn {Built-in Function} {} __go_axes__ (@var{parent})\n\ | |
6945 | 8412 Undocumented internal function.\n\ |
6406 | 8413 @end deftypefn") |
8414 { | |
8415 GO_BODY (axes); | |
8416 } | |
8417 | |
8418 DEFUN (__go_line__, args, , | |
8419 "-*- texinfo -*-\n\ | |
8420 @deftypefn {Built-in Function} {} __go_line__ (@var{parent})\n\ | |
6945 | 8421 Undocumented internal function.\n\ |
6406 | 8422 @end deftypefn") |
8423 { | |
8424 GO_BODY (line); | |
8425 } | |
8426 | |
8427 DEFUN (__go_text__, args, , | |
8428 "-*- texinfo -*-\n\ | |
8429 @deftypefn {Built-in Function} {} __go_text__ (@var{parent})\n\ | |
6945 | 8430 Undocumented internal function.\n\ |
6406 | 8431 @end deftypefn") |
8432 { | |
8433 GO_BODY (text); | |
8434 } | |
8435 | |
8436 DEFUN (__go_image__, args, , | |
8437 "-*- texinfo -*-\n\ | |
8438 @deftypefn {Built-in Function} {} __go_image__ (@var{parent})\n\ | |
6945 | 8439 Undocumented internal function.\n\ |
6406 | 8440 @end deftypefn") |
8441 { | |
8442 GO_BODY (image); | |
8443 } | |
8444 | |
8445 DEFUN (__go_surface__, args, , | |
8446 "-*- texinfo -*-\n\ | |
8447 @deftypefn {Built-in Function} {} __go_surface__ (@var{parent})\n\ | |
6945 | 8448 Undocumented internal function.\n\ |
6406 | 8449 @end deftypefn") |
8450 { | |
8451 GO_BODY (surface); | |
8452 } | |
8453 | |
6807 | 8454 DEFUN (__go_patch__, args, , |
8455 "-*- texinfo -*-\n\ | |
8456 @deftypefn {Built-in Function} {} __go_patch__ (@var{parent})\n\ | |
6945 | 8457 Undocumented internal function.\n\ |
6807 | 8458 @end deftypefn") |
8459 { | |
8460 GO_BODY (patch); | |
8461 } | |
8462 | |
7865
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8463 DEFUN (__go_hggroup__, args, , |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8464 "-*- texinfo -*-\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8465 @deftypefn {Built-in Function} {} __go_hggroup__ (@var{parent})\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8466 Undocumented internal function.\n\ |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8467 @end deftypefn") |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8468 { |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8469 GO_BODY (hggroup); |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8470 } |
b74039822fd2
Add support for hggroup
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7864
diff
changeset
|
8471 |
11155
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8472 DEFUN (__go_uimenu__, args, , |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8473 "-*- texinfo -*-\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8474 @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
|
8475 Undocumented internal function.\n\ |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8476 @end deftypefn") |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8477 { |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8478 GO_BODY (uimenu); |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8479 } |
f0e9befd6a1c
add uimenu graphic object to fltk backend
Kai Habel <kai.habel@gmx.de>
parents:
11076
diff
changeset
|
8480 |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8481 DEFUN (__go_uicontrol__, args, , |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8482 "-*- texinfo -*-\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8483 @deftypefn {Built-in Function} {} __go_uicontrol__ (@var{parent})\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8484 Undocumented internal function.\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8485 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8486 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8487 GO_BODY (uicontrol); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8488 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8489 |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8490 DEFUN (__go_uipanel__, args, , |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8491 "-*- texinfo -*-\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8492 @deftypefn {Built-in Function} {} __go_uipanel__ (@var{parent})\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8493 Undocumented internal function.\n\ |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8494 @end deftypefn") |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8495 { |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8496 GO_BODY (uipanel); |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8497 } |
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8498 |
13703
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8499 DEFUN (__go_uicontextmenu__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8500 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8501 @deftypefn {Built-in Function} {} __go_uicontextmenu__ (@var{parent})\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8502 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8503 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8504 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8505 GO_BODY (uicontextmenu); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8506 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8507 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8508 DEFUN (__go_uitoolbar__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8509 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8510 @deftypefn {Built-in Function} {} __go_uitoolbar__ (@var{parent})\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8511 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8512 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8513 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8514 GO_BODY (uitoolbar); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8515 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8516 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8517 DEFUN (__go_uipushtool__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8518 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8519 @deftypefn {Built-in Function} {} __go_uipushtool__ (@var{parent})\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8520 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8521 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8522 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8523 GO_BODY (uipushtool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8524 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8525 |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8526 DEFUN (__go_uitoggletool__, args, , |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8527 "-*- texinfo -*-\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8528 @deftypefn {Built-in Function} {} __go_uitoggletool__ (@var{parent})\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8529 Undocumented internal function.\n\ |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8530 @end deftypefn") |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8531 { |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8532 GO_BODY (uitoggletool); |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8533 } |
22ce748da25f
Add missing UI objects: uicontextmenu, uitoolbar, uipushtool and uitoggletool.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13327
diff
changeset
|
8534 |
6406 | 8535 DEFUN (__go_delete__, args, , |
8536 "-*- texinfo -*-\n\ | |
8537 @deftypefn {Built-in Function} {} __go_delete__ (@var{h})\n\ | |
6945 | 8538 Undocumented internal function.\n\ |
6406 | 8539 @end deftypefn") |
8540 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8541 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8542 |
6406 | 8543 octave_value_list retval; |
8544 | |
8545 if (args.length () == 1) | |
8546 { | |
8547 graphics_handle h = octave_NaN; | |
8548 | |
8196
32e9e8103390
Allow arrays of graphic handles to F__go_delete__
David Bateman <dbateman@free.fr>
parents:
8183
diff
changeset
|
8549 const NDArray vals = args (0).array_value (); |
6406 | 8550 |
8551 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8552 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8553 // 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
|
8554 // 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
|
8555 // later want to delete |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8556 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
|
8557 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8558 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8559 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8560 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8561 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8562 error ("delete: invalid graphics object (= %g)", |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8563 vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8564 break; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8565 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8566 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8567 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8568 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8569 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8570 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
|
8571 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8572 h = gh_manager::lookup (vals.elem (i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8573 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8574 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8575 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8576 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8577 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8578 // Don't do recursive deleting, due to callbacks |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8579 if (! obj.get_properties ().is_beingdeleted ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8580 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8581 graphics_handle parent_h = obj.get_parent (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8582 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8583 graphics_object parent_obj = |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8584 gh_manager::get_object (parent_h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8585 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8586 // NOTE: free the handle before removing it from its |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8587 // parent's children, such that the object's |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8588 // state is correct when the deletefcn callback |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8589 // is executed |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8590 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8591 gh_manager::free (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8592 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8593 // A callback function might have already deleted |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8594 // the parent |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8595 if (parent_obj.valid_object ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8596 parent_obj.remove_child (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8597 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8598 Vdrawnow_requested = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8599 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8600 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8601 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8602 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8603 } |
6406 | 8604 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8605 error ("delete: invalid graphics object"); |
6406 | 8606 } |
8607 else | |
8608 print_usage (); | |
8609 | |
8610 return retval; | |
8611 } | |
8612 | |
8613 DEFUN (__go_axes_init__, args, , | |
8614 "-*- texinfo -*-\n\ | |
8615 @deftypefn {Built-in Function} {} __go_axes_init__ (@var{h}, @var{mode})\n\ | |
6945 | 8616 Undocumented internal function.\n\ |
6406 | 8617 @end deftypefn") |
8618 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8619 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8620 |
6406 | 8621 octave_value retval; |
8622 | |
8623 int nargin = args.length (); | |
8624 | |
8625 std::string mode = ""; | |
8626 | |
8627 if (nargin == 2) | |
8628 { | |
8629 mode = args(1).string_value (); | |
8630 | |
8631 if (error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8632 return retval; |
6406 | 8633 } |
8634 | |
8635 if (nargin == 1 || nargin == 2) | |
8636 { | |
8637 graphics_handle h = octave_NaN; | |
8638 | |
8639 double val = args(0).double_value (); | |
8640 | |
8641 if (! error_state) | |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8642 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8643 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8644 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8645 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8646 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8647 graphics_object obj = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8648 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8649 obj.set_defaults (mode); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8650 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8651 h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8652 if (! h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8653 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
|
8654 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8655 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8656 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
|
8657 } |
6406 | 8658 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8659 error ("__go_axes_init__: invalid graphics object"); |
6406 | 8660 } |
8661 else | |
8662 print_usage (); | |
8663 | |
8664 return retval; | |
8665 } | |
8666 | |
8667 DEFUN (__go_handles__, , , | |
8668 "-*- texinfo -*-\n\ | |
8669 @deftypefn {Built-in Function} {} __go_handles__ ()\n\ | |
6945 | 8670 Undocumented internal function.\n\ |
6406 | 8671 @end deftypefn") |
8672 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8673 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8674 |
6425 | 8675 return octave_value (gh_manager::handle_list ()); |
8676 } | |
8677 | |
8678 DEFUN (__go_figure_handles__, , , | |
8679 "-*- texinfo -*-\n\ | |
8680 @deftypefn {Built-in Function} {} __go_figure_handles__ ()\n\ | |
6945 | 8681 Undocumented internal function.\n\ |
6425 | 8682 @end deftypefn") |
8683 { | |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8684 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8685 |
6425 | 8686 return octave_value (gh_manager::figure_handle_list ()); |
6406 | 8687 } |
8688 | |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8689 DEFUN (__go_execute_callback__, args, , |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8690 "-*- texinfo -*-\n\ |
10840 | 8691 @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
|
8692 @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
|
8693 Undocumented internal function.\n\ |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8694 @end deftypefn") |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8695 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8696 octave_value retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8697 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8698 int nargin = args.length (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8699 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8700 if (nargin == 2 || nargin == 3) |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8701 { |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8702 double val = args(0).double_value (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8703 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8704 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8705 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8706 graphics_handle h = gh_manager::lookup (val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8707 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8708 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8709 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8710 std::string name = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8711 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8712 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8713 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8714 if (nargin == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8715 gh_manager::execute_callback (h, name); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8716 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8717 gh_manager::execute_callback (h, name, args(2)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8718 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8719 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8720 error ("__go_execute_callback__: invalid callback name"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8721 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8722 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8723 error ("__go_execute_callback__: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8724 val); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8725 } |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8726 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8727 error ("__go_execute_callback__: invalid graphics object"); |
7967
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8728 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8729 else |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8730 print_usage (); |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8731 |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8732 return retval; |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8733 } |
6add0f974aee
Add __go_execute_callback__
John W. Eaton <jwe@octave.org>
parents:
7964
diff
changeset
|
8734 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8735 DEFUN (__image_pixel_size__, args, , |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8736 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
8737 @deftypefn {Built-in Function} {@var{px}, @var{py}} __image_pixel_size__ (@var{h})\n\ |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8738 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
|
8739 @end deftypefn") |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8740 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8741 octave_value retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8742 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8743 int nargin = args.length (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8744 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8745 if (nargin == 1) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8746 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8747 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
|
8748 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8749 if (! error_state) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8750 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8751 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
|
8752 if (fobj && fobj.isa ("image")) |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8753 { |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8754 image::properties& ip = |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8755 dynamic_cast<image::properties&> (fobj.get_properties ()); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11576
diff
changeset
|
8756 |
11076
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8757 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
|
8758 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
|
8759 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
|
8760 retval = dp; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8761 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8762 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8763 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
|
8764 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8765 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8766 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
|
8767 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8768 else |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8769 print_usage (); |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8770 |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8771 return retval; |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8772 } |
b748b86cb8c1
fix images with width or height of 1
Shai Ayal <shaiay@users.sourceforge.net>
parents:
11074
diff
changeset
|
8773 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8774 DEFUN (available_graphics_toolkits, , , |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
8775 "-*- texinfo -*-\n\ |
12215
4ae2a74ed04c
Add fltk_gui_mode, fltk_mouse_wheel_zoom to documentation.
Rik <octave@nomad.inbox5.com>
parents:
12189
diff
changeset
|
8776 @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\ |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8777 Return a cell array of registered graphics toolkits.\n\ |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
8778 @end deftypefn") |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
8779 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8780 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8781 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8782 return octave_value (graphics_toolkit::available_toolkits_list ()); |
7835
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
8783 } |
ca8b97bb952c
added the function available_backends
Shai Ayal <shaiay@sourceforge.net>
parents:
7833
diff
changeset
|
8784 |
7408 | 8785 DEFUN (drawnow, args, , |
8786 "-*- texinfo -*-\n\ | |
9316
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
8787 @deftypefn {Built-in Function} {} drawnow ()\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
8788 @deftypefnx {Built-in Function} {} drawnow (\"expose\")\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
8789 @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
|
8790 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
|
8791 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
|
8792 @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
|
8793 callbacks are processed.\n\ |
c539ec5726e7
Update some of Advanced Plotting documentation.
Rik <rdrider0-list@yahoo.com>
parents:
9311
diff
changeset
|
8794 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
|
8795 undocumented.\n\ |
7408 | 8796 @end deftypefn") |
8797 { | |
8798 static int drawnow_executing = 0; | |
8799 static bool __go_close_all_registered__ = false; | |
8800 | |
8801 octave_value retval; | |
8802 | |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8803 gh_manager::lock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8804 |
10066
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
8805 unwind_protect frame; |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
8806 frame.protect_var (Vdrawnow_requested, false); |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
8807 |
2cd940306a06
make unwind_protect frames local
Jaroslav Hajek <highegg@gmail.com>
parents:
10056
diff
changeset
|
8808 frame.protect_var (drawnow_executing); |
7409 | 8809 |
8810 if (++drawnow_executing <= 1) | |
7408 | 8811 { |
7409 | 8812 if (! __go_close_all_registered__) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8813 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8814 octave_add_atexit_function ("__go_close_all__"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8815 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8816 __go_close_all_registered__ = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8817 } |
7409 | 8818 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8819 if (args.length () == 0 || args.length () == 1) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8820 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8821 Matrix hlist = gh_manager::figure_handle_list (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8822 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8823 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
|
8824 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8825 graphics_handle h = gh_manager::lookup (hlist(i)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8826 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8827 if (h.ok () && h != 0) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8828 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8829 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8830 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
|
8831 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8832 if (fprops.is_modified ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8833 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8834 if (fprops.is_visible ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8835 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8836 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8837 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8838 fprops.get_toolkit ().redraw_figure (go); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8839 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8840 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8841 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8842 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8843 fprops.set_modified (false); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8844 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8845 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8846 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8847 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8848 bool do_events = true; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8849 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8850 if (args.length () == 1) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8851 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8852 caseless_str val (args(0).string_value ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8853 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8854 if (! error_state && val.compare ("expose")) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8855 do_events = false; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8856 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8857 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8858 error ("drawnow: invalid argument, expected `expose' as argument"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8859 return retval; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8860 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8861 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8862 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8863 if (do_events) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8864 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8865 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8866 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8867 gh_manager::process_events (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8868 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8869 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8870 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8871 } |
7409 | 8872 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
|
8873 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8874 std::string term, file, debug_file; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8875 bool mono; |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8876 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8877 term = args(0).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8878 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8879 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8880 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8881 file = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8882 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8883 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8884 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8885 size_t pos = file.find_first_not_of ("|"); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8886 if (pos > 0) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8887 file = file.substr (pos); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8888 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8889 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8890 pos = file.find_last_of (file_ops::dir_sep_chars ()); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8891 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8892 if (pos != std::string::npos) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8893 { |
12449
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8894 std::string dirname = file.substr (0, pos+1); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8895 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8896 file_stat fs (dirname); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8897 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8898 if (! (fs && fs.is_dir ())) |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8899 { |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8900 error ("drawnow: nonexistent directory `%s'", |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8901 dirname.c_str ()); |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8902 |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8903 return retval; |
2f0d1e12806d
invoke/terminate printing process synchronously with rendering (#32319)
Konstantinos Poulios <logari81@gmail.com>
parents:
12445
diff
changeset
|
8904 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8905 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8906 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8907 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8908 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
|
8909 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8910 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8911 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8912 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
|
8913 : ""); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8914 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8915 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8916 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8917 graphics_handle h = gcf (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8918 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8919 if (h.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8920 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8921 graphics_object go = gh_manager::get_object (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8922 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8923 gh_manager::unlock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8924 |
11576
8ac9687dbe9f
rename backend to graphics_toolkit
John W. Eaton <jwe@octave.org>
parents:
11572
diff
changeset
|
8925 go.get_toolkit () |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8926 .print_figure (go, term, file, mono, debug_file); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8927 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8928 gh_manager::lock (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8929 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8930 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8931 error ("drawnow: nothing to draw"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8932 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8933 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
8934 error ("drawnow: invalid DEBUG_FILE, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8935 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8936 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
8937 error ("drawnow: invalid colormode MONO, expected a boolean value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8938 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8939 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
8940 error ("drawnow: invalid FILE, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8941 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8942 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
8943 error ("drawnow: invalid terminal TERM, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8944 } |
7408 | 8945 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8946 print_usage (); |
7408 | 8947 } |
7409 | 8948 |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8949 gh_manager::unlock (); |
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8950 |
7408 | 8951 return retval; |
8952 } | |
8953 | |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
8954 DEFUN (addlistener, args, , |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8955 "-*- texinfo -*-\n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
8956 @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
|
8957 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
|
8958 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
|
8959 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
|
8960 listeners are executed.\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8961 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8962 @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
|
8963 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8964 @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
|
8965 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
|
8966 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
|
8967 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
|
8968 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
|
8969 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
|
8970 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
|
8971 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
|
8972 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
8973 Example:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
8974 \n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8975 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
8976 @group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8977 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
|
8978 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
|
8979 endfunction\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8980 \n\ |
7859
fdd465b00ec0
Rename add_listener to addlistener.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7857
diff
changeset
|
8981 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
|
8982 @end group\n\ |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8983 @end example\n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8984 \n\ |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8985 @end deftypefn") |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8986 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
8987 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
8988 |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8989 octave_value retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8990 |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
8991 if (args.length () >= 3 && args.length () <= 4) |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8992 { |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8993 double h = args(0).double_value (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8994 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
8995 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8996 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8997 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8998 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
8999 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9000 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9001 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9002 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9003 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9004 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9005 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9006 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9007 go.add_property_listener (pname, args(2), POSTSET); |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9008 |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9009 if (args.length () == 4) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9010 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9011 caseless_str persistent = args(3).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9012 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9013 go.add_property_listener (pname, args(2), PERSISTENT); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9014 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9015 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9016 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9017 error ("addlistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9018 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9019 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9020 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9021 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
|
9022 } |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9023 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9024 error ("addlistener: invalid handle"); |
7849
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9025 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9026 else |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9027 print_usage (); |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9028 |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9029 return retval; |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9030 } |
3249f64f69b2
Initial low-level support for property listeners.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7848
diff
changeset
|
9031 |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9032 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
|
9033 "-*- texinfo -*-\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9034 @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
|
9035 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
|
9036 @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
|
9037 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
|
9038 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
|
9039 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9040 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
|
9041 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
|
9042 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9043 Example:\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9044 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9045 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9046 @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
|
9047 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
|
9048 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
|
9049 endfunction\n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9050 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9051 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
|
9052 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
|
9053 dellistener (gcf, \"position\", c);\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9054 @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
|
9055 @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
|
9056 \n\ |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9057 @end deftypefn") |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9058 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9059 gh_manager::auto_lock guard; |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9060 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9061 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
|
9062 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9063 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
|
9064 { |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9065 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
|
9066 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9067 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9068 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9069 std::string pname = args(1).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9070 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9071 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9072 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9073 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9074 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9075 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9076 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9077 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9078 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9079 if (args.length () == 2) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9080 go.delete_property_listener (pname, octave_value (), POSTSET); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9081 else |
12506
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9082 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9083 caseless_str persistent = args(2).string_value (); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9084 if (persistent.compare ("persistent")) |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9085 { |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9086 go.delete_property_listener (pname, octave_value (), PERSISTENT); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9087 go.delete_property_listener (pname, octave_value (), POSTSET); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9088 } |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9089 else |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9090 go.delete_property_listener (pname, args(2), POSTSET); |
0dda50ae4997
add a persistent mode for listeners
Konstantinos Poulios <logari81@gmail.com>
parents:
12502
diff
changeset
|
9091 } |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9092 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9093 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9094 error ("dellistener: invalid graphics object (= %g)", |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9095 h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9096 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9097 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9098 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
|
9099 } |
8299
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9100 else |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9101 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
|
9102 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9103 else |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9104 print_usage (); |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9105 |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9106 return retval; |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9107 } |
be9b14945774
Add code to remove listeners from properties and use it with newplot
David Bateman <dbateman@free.fr>
parents:
8291
diff
changeset
|
9108 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9109 DEFUN (addproperty, args, , |
7869 | 9110 "-*- texinfo -*-\n\ |
11572
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
9111 @deftypefn {Built-in Function} {} addproperty (@var{name}, @var{h}, @var{type})\n\ |
7d6d8c1e471f
Grammarcheck Texinfo for files in src directory.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
9112 @deftypefnx {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
|
9113 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
|
9114 @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
|
9115 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
|
9116 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
|
9117 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9118 The supported property types are:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9119 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9120 @table @code\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9121 @item string\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9122 A string property. @var{arg} contains the default string value.\n\ |
10840 | 9123 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9124 @item any\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9125 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
|
9126 value. @var{args} contains the default value.\n\ |
10840 | 9127 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9128 @item radio\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9129 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
|
9130 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
|
9131 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
|
9132 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
|
9133 an optional second string argument.\n\ |
10840 | 9134 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9135 @item boolean\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9136 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
|
9137 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
|
9138 the default property value.\n\ |
10840 | 9139 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9140 @item double\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9141 A scalar double property. @var{arg} contains the default value.\n\ |
10840 | 9142 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9143 @item handle\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9144 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
|
9145 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
|
9146 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
|
9147 the empty matrix.\n\ |
10840 | 9148 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9149 @item data\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9150 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
|
9151 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
|
9152 the empty matrix.\n\ |
10840 | 9153 \n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9154 @item color\n\ |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8961
diff
changeset
|
9155 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
|
9156 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
|
9157 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
|
9158 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
|
9159 @end table\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9160 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9161 @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
|
9162 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
|
9163 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
|
9164 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
|
9165 property into the graphics object @var{h}.\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9166 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9167 Examples:\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9168 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9169 @example\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9170 @group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9171 addproperty (\"my_property\", gcf, \"string\", \"a string value\");\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9172 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
|
9173 addproperty (\"my_style\", gcf, \"linelinestyle\", \"--\");\n\ |
9064
7c02ec148a3c
Check grammar on all .cc files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
9174 @end group\n\ |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9175 @end example\n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9176 \n\ |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9177 @end deftypefn") |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9178 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9179 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9180 |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9181 octave_value retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9182 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9183 if (args.length () >= 3) |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9184 { |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9185 std::string name = args(0).string_value (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9186 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9187 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9188 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9189 double h = args(1).double_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9190 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9191 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9192 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9193 graphics_handle gh = gh_manager::lookup (h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9194 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9195 if (gh.ok ()) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9196 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9197 graphics_object go = gh_manager::get_object (gh); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9198 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9199 std::string type = args(2).string_value (); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9200 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9201 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9202 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9203 if (! go.get_properties ().has_property (name)) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9204 { |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9205 property p = property::create (name, gh, type, |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9206 args.splice (0, 3)); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9207 |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9208 if (! error_state) |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9209 go.get_properties ().insert_property (name, p); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9210 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9211 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9212 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
|
9213 name.c_str ()); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9214 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9215 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9216 error ("addproperty: invalid property TYPE, expected a string value"); |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9217 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9218 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9219 error ("addproperty: invalid graphics object (= %g)", h); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9220 } |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9221 else |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9222 error ("addproperty: invalid handle value"); |
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9223 } |
7864
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9224 else |
12483
7a5aacf65f81
Rewrite error strings in src/ to use variables named in documentation.
Rik <octave@nomad.inbox5.com>
parents:
12467
diff
changeset
|
9225 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
|
9226 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9227 else |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9228 print_usage (); |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9229 |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9230 return retval; |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9231 } |
56f781f38f0b
Add dynamic property creation
Michael Goffioul <michael.goffioul@gmail.com>
parents:
7862
diff
changeset
|
9232 |
6595 | 9233 octave_value |
7447 | 9234 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
|
9235 const std::string& func) |
6595 | 9236 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9237 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9238 |
6595 | 9239 graphics_object obj = gh_manager::get_object (handle); |
9240 octave_value retval; | |
9241 | |
9242 if (obj) | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9243 retval = obj.get (caseless_str (property)); |
6595 | 9244 else |
9245 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
9246 | |
9247 return retval; | |
9248 } | |
9249 | |
9250 bool | |
7447 | 9251 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
|
9252 const octave_value& arg, const std::string& func) |
6595 | 9253 { |
13281
834f904a3dcb
Add support for full asynchronous graphics toolkit running in a separate
Michael Goffioul <michael.goffioul@gmail.com>
parents:
13247
diff
changeset
|
9254 gh_manager::auto_lock guard; |
7936
78400fde223e
Support for backend-to-octave event management
John W. Eaton <jwe@octave.org>
parents:
7924
diff
changeset
|
9255 |
6595 | 9256 graphics_object obj = gh_manager::get_object (handle); |
9257 int ret = false; | |
9258 | |
9259 if (obj) | |
9260 { | |
9582
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9261 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
|
9262 |
bdcfb756d721
improve error messages for ambiguous graphics property names
John W. Eaton <jwe@octave.org>
parents:
9561
diff
changeset
|
9263 if (! error_state) |
10315
57a59eae83cc
untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents:
10301
diff
changeset
|
9264 ret = true; |
6595 | 9265 } |
9266 else | |
9267 error ("%s: invalid handle (= %g)", func.c_str(), handle); | |
9268 | |
9269 return ret; | |
9270 } |